import { ZodSchema, z } from 'zod'; /** * @fileoverview CON-04 Runtime Validation - Payload Validation * @description Centralized validation function using Zod schemas * @version 0.18.4 */ /** * Validates a payload against a Zod schema and returns the parsed result * Throws a ValidationError if validation fails * * @param schema - Zod schema to validate against * @param data - Unknown data to validate * @returns Parsed and validated data * @throws {ValidationError} if validation fails * * @example * ```typescript * const userSchema = z.object({ * id: z.string(), * email: z.string().email(), * name: z.string() * }); * * const userData = { id: "123", email: "user@example.com", name: "John" }; * const validUser = validatePayload(userSchema, userData); * // validUser is now typed as { id: string, email: string, name: string } * ``` */ declare function validatePayload(schema: ZodSchema, data: unknown): T; /** * Safely validates a payload and returns a result object * Does not throw - useful for optional validation or graceful degradation * * @param schema - Zod schema to validate against * @param data - Unknown data to validate * @returns Validation result with success flag and data/error * * @example * ```typescript * const result = safeValidatePayload(userSchema, inputData); * if (result.success) { * // result.data is properly typed * console.log(result.data.email); * } else { * // result.error contains the ZodError * console.error(result.error.format()); * } * ``` */ declare function safeValidatePayload(schema: ZodSchema, data: unknown): { success: true; data: T; } | { success: false; error: z.ZodError; }; /** * @fileoverview CON-04 Runtime Validation - Envelope Validation * @description Validation functions for API response envelopes * @version 0.18.4 */ /** * Validates that a response follows the standard API envelope format * * @param response - Unknown response to validate * @throws {EnvelopeValidationError} if response doesn't match envelope format * * @example * ```typescript * const response = { success: true, data: { id: "123" }, meta: {} }; * validateStandardEnvelope(response); * // Throws if response doesn't match standard envelope format * ``` */ declare function validateStandardEnvelope(response: unknown): asserts response is { success: boolean; data?: any; error?: any; meta?: Record; }; /** * Validates that a response follows the enhanced API envelope format * * @param response - Unknown response to validate * @throws {EnvelopeValidationError} if response doesn't match enhanced envelope format */ declare function validateEnhancedEnvelope(response: unknown): asserts response is { success: boolean; data?: any; error?: any; requestId: string; timestamp: string; meta?: { contractsVersion: string; traceId?: string; latencyMs?: number; source?: string; }; }; /** * Creates a combined schema that validates both envelope and data structure * This is the primary function for validating API responses with data * * @param dataSchema - Zod schema for the expected data structure * @returns Zod schema that validates envelope + data * * @example * ```typescript * const userSchema = z.object({ * id: z.string(), * email: z.string().email() * }); * * const envelopeWithUser = validateEnvelope(userSchema); * const response = { * success: true, * data: { id: "123", email: "user@example.com" } * }; * * const result = envelopeWithUser.parse(response); * // result.data is now typed as { id: string, email: string } * ``` */ declare function validateEnvelope(dataSchema: ZodSchema): z.ZodObject<{ success: z.ZodBoolean; error: z.ZodOptional>; timestamp: z.ZodString; }, "strict", z.ZodTypeAny, { code: string; message: string; timestamp: string; details?: Record | undefined; }, { code: string; message: string; timestamp: string; details?: Record | undefined; }>>; meta: z.ZodOptional>; } & { data: z.ZodType; }, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks>; timestamp: z.ZodString; }, "strict", z.ZodTypeAny, { code: string; message: string; timestamp: string; details?: Record | undefined; }, { code: string; message: string; timestamp: string; details?: Record | undefined; }>>; meta: z.ZodOptional>; } & { data: z.ZodType; }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{ success: z.ZodBoolean; error: z.ZodOptional>; timestamp: z.ZodString; }, "strict", z.ZodTypeAny, { code: string; message: string; timestamp: string; details?: Record | undefined; }, { code: string; message: string; timestamp: string; details?: Record | undefined; }>>; meta: z.ZodOptional>; } & { data: z.ZodType; }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>; /** * Validates an error response according to the standard error envelope format * * @param response - Unknown error response to validate * @throws {EnvelopeValidationError} if error response doesn't match expected format */ declare function validateErrorEnvelope(response: unknown): asserts response is { success: false; error: { code: string; message: string; details?: Record; timestamp: string; }; meta?: Record; }; /** * Safely validates an envelope without throwing * Useful for graceful error handling * * @param dataSchema - Zod schema for the expected data structure * @param response - Unknown response to validate * @returns Validation result with success flag and data/error */ declare function safeValidateEnvelope(dataSchema: ZodSchema, response: unknown): { success: true; data: T; } | { success: false; error: z.ZodError; }; /** * @fileoverview CON-04 Runtime Validation - Type Guard Factory * @description Composable type-guard helpers and factory functions * @version 0.18.4 */ /** * Creates a type guard function from a Zod schema * Useful for runtime type checking in FE/Infra/ML code * * @param schema - Zod schema to create guard for * @param errorMessage - Optional custom error message * @returns Type guard function * * @example * ```typescript * const isUser = createTypeGuard(userSchema); * * function processUser(data: unknown) { * if (isUser(data)) { * // TypeScript knows data is User type here * console.log(data.email); * } else { * console.log("Invalid user data"); * } * } * ``` */ declare function createTypeGuard(schema: ZodSchema, errorMessage?: string): (obj: unknown) => obj is T; /** * Creates a strict type guard that throws TypeGuardError on validation failure * Useful when you need to ensure type safety at runtime * * @param schema - Zod schema to create guard for * @param errorMessage - Optional custom error message * @returns Type guard function that throws on validation failure * * @example * ```typescript * const assertIsUser = createStrictTypeGuard(userSchema, "Invalid user data"); * * function processUser(data: unknown) { * assertIsUser(data); // Throws if data is invalid * // TypeScript knows data is User type here * console.log(data.email); * } * ``` */ declare function createStrictTypeGuard(schema: ZodSchema, errorMessage?: string): (obj: unknown) => asserts obj is T; /** * Creates a safe type guard that returns a result object * Useful for graceful type checking without exceptions * * @param schema - Zod schema to create guard for * @returns Safe type guard function * * @example * ```typescript * const safeIsUser = createSafeTypeGuard(userSchema); * * function processUser(data: unknown) { * const result = safeIsUser(data); * if (result.success) { * // result.data is properly typed * console.log(result.data.email); * } else { * // result.error contains the ZodError * console.error("Invalid user:", result.error.format()); * } * } * ``` */ declare function createSafeTypeGuard(schema: ZodSchema): (obj: unknown) => { success: true; data: T; } | { success: false; error: z.ZodError; }; /** * Combines multiple type guards with AND logic * All guards must pass for the combined guard to pass * * @param guards - Array of type guard functions * @returns Combined type guard function * * @example * ```typescript * const isAdultUser = combineGuards([ * isUser, * (u): u is User & { age: number } => u.age >= 18 * ]); * ``` */ declare function combineGuards(guards: Array<(obj: unknown) => obj is T>): (obj: unknown) => obj is T; /** * Combines multiple type guards with OR logic * At least one guard must pass for the combined guard to pass * * @param guards - Array of type guard functions * @returns Combined type guard function * * @example * ```typescript * const isUserOrAdmin = combineGuardsOr([ * isUser, * isAdmin * ]); * ``` */ declare function combineGuardsOr(guards: Array<(obj: unknown) => obj is T>): (obj: unknown) => obj is T; /** * Creates a type guard for array elements * Validates that all elements in an array match the schema * * @param schema - Zod schema for array elements * @returns Type guard for arrays * * @example * ```typescript * const isUserArray = createArrayGuard(userSchema); * * function processUsers(data: unknown) { * if (isUserArray(data)) { * // TypeScript knows data is User[] * data.forEach(user => console.log(user.email)); * } * } * ``` */ declare function createArrayGuard(schema: ZodSchema): (obj: unknown) => obj is T[]; /** * Creates a type guard for optional values * Validates that a value is either undefined or matches the schema * * @param schema - Zod schema for the value type * @returns Type guard for optional values * * @example * ```typescript * const isOptionalUser = createOptionalGuard(userSchema); * * function processUser(data: unknown) { * if (isOptionalUser(data)) { * // TypeScript knows data is User | undefined * if (data) { * console.log(data.email); * } * } * } * ``` */ declare function createOptionalGuard(schema: ZodSchema): (obj: unknown) => obj is T | undefined; /** * @fileoverview CON-03 RouteRegistry - Route Schema Linking & Envelope Automation * @description Canonical registry linking API routes to their Zod schemas for type-safe routing * @version 0.18.4-alpha */ /** * Route definition interface for type-safe route registration */ interface RouteDefinition { path: string; method: "GET" | "POST" | "PUT" | "DELETE"; request?: z.ZodSchema; response?: z.ZodSchema; description?: string; deprecated?: boolean; version?: string; } /** * Canonical RouteRegistry - Single source of truth for all route definitions * Maps ROUTES constants to their Zod schemas for type-safe routing and validation */ declare const RouteRegistry: Record; /** * Route request type helper */ type RouteRequest = typeof RouteRegistry[K]["request"] extends z.ZodSchema ? T : never; /** * Route response type helper */ type RouteResponse = typeof RouteRegistry[K]["response"] extends z.ZodSchema ? T : never; /** * Registry metadata */ declare const ROUTE_REGISTRY_METADATA: { readonly version: "0.18.4-alpha"; readonly totalRoutes: number; readonly canonicalRoutes: number; readonly deprecatedRoutes: number; readonly created: string; }; /** * === RUNTIME VALIDATION HOOKS (Phase 5) === * Type-safe validation functions for runtime use */ /** * Asserts that a payload is a valid response for the specified route * Provides compile-time route path validation and runtime schema validation * * @param route - Route path from RouteRegistry * @param payload - Response payload to validate * @throws {ZodError} if payload doesn't match route's expected response schema * * @example * ```typescript * // In infra/frontend tests or API clients: * const response = await fetchPortfolioSummary(); * assertValidResponse(ROUTES.INFRA.PORTFOLIO.SUMMARY, response); * // TypeScript now knows response is properly typed and validated * ``` */ declare function assertValidResponse(route: K, payload: unknown): asserts payload is { success: boolean; data: RouteResponse; meta?: Record; error?: any; }; /** * Asserts that a payload is a valid request for the specified route * Provides compile-time route path validation and runtime schema validation * * @param route - Route path from RouteRegistry * @param payload - Request payload to validate * @throws {ZodError} if payload doesn't match route's expected request schema * * @example * ```typescript * // In infra/frontend before making requests: * const requestData = { email: "user@example.com", password: "secret" }; * assertValidRequest(ROUTES.AUTH.LOGIN, requestData); * // TypeScript now knows requestData is properly typed and validated * ``` */ declare function assertValidRequest(route: K, payload: unknown): asserts payload is RouteRequest; /** * Validates response data without the envelope wrapper * Useful for internal processing where envelope is already stripped * * @param route - Route path from RouteRegistry * @param data - Response data to validate * @throws {ZodError} if data doesn't match route's expected response schema */ declare function assertValidResponseData(route: K, data: unknown): asserts data is RouteResponse; /** * Type-safe route response validator for specific routes * Enhanced version that provides better error messages * * @param routePath - Route path from RouteRegistry * @param payload - Response payload to validate * @throws {ZodError} if payload doesn't match route's expected response schema */ declare function validateRouteResponse(routePath: K, payload: unknown): asserts payload is { success: boolean; data: RouteResponse; meta?: Record; error?: any; }; /** * Type-safe route request validator for specific routes * Enhanced version that provides better error messages * * @param routePath - Route path from RouteRegistry * @param payload - Request payload to validate * @throws {ZodError} if payload doesn't match route's expected request schema */ declare function validateRouteRequest(routePath: K, payload: unknown): asserts payload is RouteRequest; /** * Utility function to get route information at runtime * Useful for debugging and dynamic route handling * * @param routePath - Route path to look up * @returns Route definition or undefined if not found */ declare function getRouteInfo(routePath: K): RouteDefinition | undefined; /** * Get all routes for a specific HTTP method * * @param method - HTTP method to filter by * @returns Array of route paths that use the specified method */ declare function getRoutesByMethod(method: "GET" | "POST" | "PUT" | "DELETE"): RoutePaths[]; /** * Get all active (non-deprecated) routes * * @returns Array of active route paths */ declare function getActiveRoutes(): RoutePaths[]; /** * Get all deprecated routes * * @returns Array of deprecated route paths */ declare function getDeprecatedRoutes(): RoutePaths[]; /** * Type-safe route paths - all keys from RouteRegistry */ type RoutePaths = keyof typeof RouteRegistry; /** * Export route paths as string values for runtime use */ declare const RoutePaths: RoutePaths[]; /** * @fileoverview CON-04 Runtime Validation Errors * @description Standardized error classes for validation failures * @version 0.18.4 */ /** * Base validation error class for runtime validation failures * Extends Error to maintain compatibility with existing error handling */ declare class ValidationError extends Error { readonly details?: Record; readonly timestamp: string; readonly code: string; constructor(message: string, code?: string, cause?: Error | unknown, details?: Record); /** * Convert to JSON for logging/serialization */ toJSON(): { name: string; code: string; message: string; details: Record | undefined; timestamp: string; stack: string | undefined; cause: unknown; }; } /** * Error thrown when payload validation fails */ declare class PayloadValidationError extends ValidationError { constructor(message: string, code?: string, cause?: Error | unknown, details?: Record); } /** * Error thrown when envelope validation fails */ declare class EnvelopeValidationError extends ValidationError { constructor(message: string, code?: string, cause?: Error | unknown, details?: Record); } /** * Error thrown when type guard validation fails */ declare class TypeGuardError extends ValidationError { constructor(message: string, code?: string, cause?: Error | unknown, details?: Record); } /** * Error thrown when route validation fails */ declare class RouteValidationError extends ValidationError { constructor(message: string, code?: string, cause?: Error | unknown, details?: Record); } /** * @fileoverview v0.18.0 Canonical Routes - /api/infra/* Standardization * Infrastructure Team Consensus: Standardize on /api/infra/* as canonical pattern * Purpose: Unified API surface with enhanced endpoints from Infrastructure audit */ declare const AUTH_ROUTES: { readonly LOGIN: "/api/auth/login"; readonly LOGOUT: "/api/auth/logout"; readonly REFRESH: "/api/auth/refresh"; readonly VALIDATE: "/api/auth/validate"; readonly JWKS: "/api/auth/jwks"; readonly WHOAMI: "/api/auth/whoami"; readonly PERMISSIONS: "/api/auth/permissions"; readonly SESSION: "/api/auth/session"; readonly SESSION_VALIDATE: "/api/auth/session/validate"; readonly TOKEN_REFRESH: "/api/auth/token/refresh"; readonly LOGOUT_ALL: "/api/auth/logout/all"; }; declare const USER_ROUTES: { readonly PROFILE: "/api/user/profile"; readonly PREFERENCES: "/api/user/preferences"; readonly SESSIONS: "/api/user/sessions"; readonly ORGANIZATIONS: "/api/user/organizations"; readonly ROLES: "/api/user/roles"; readonly ACTIVITY: "/api/user/activity"; readonly SETTINGS: "/api/user/settings"; readonly NOTIFICATIONS: "/api/user/notifications"; }; declare const ADMIN_ROUTES: { readonly USERS: "/api/admin/users"; readonly ROLES: "/api/admin/roles"; readonly PERMISSIONS: "/api/admin/permissions"; readonly SYSTEM: "/api/admin/system"; readonly AUDIT: "/api/admin/audit"; readonly ORGANIZATIONS: "/api/admin/organizations"; readonly SECURITY: "/api/admin/security"; readonly MONITORING: "/api/admin/monitoring"; }; declare const INFRA_ROUTES: { readonly PORTFOLIO: { readonly SUMMARY: "/api/infra/portfolio/summary"; readonly ACCOUNTS: "/api/infra/portfolio/accounts"; readonly HOLDINGS: "/api/infra/portfolio/holdings"; readonly INVESTMENTS: "/api/infra/portfolio/investments"; readonly MANUAL_ADD: "/api/infra/portfolio/manual/add"; readonly SNAPSHOTS: "/api/infra/portfolio/snapshots"; readonly VALUE: "/api/infra/portfolio/value"; readonly SYNC: "/api/infra/portfolio/sync"; }; readonly MARKET: { readonly OHLCV: "/api/infra/market/data/ohlcv"; readonly INDICATORS: "/api/infra/market/data/indicators"; readonly BARS: "/api/infra/market/data/bars"; readonly PRECOMPUTED: "/api/infra/market/data/precomputed"; readonly UNIVERSE: "/api/infra/market/meta/universe"; readonly TIMEFRAMES: "/api/infra/market/meta/timeframes"; readonly STATUS: "/api/infra/market/meta/status"; readonly PROVIDERS: "/api/infra/market/meta/providers"; readonly STORE_BARS: "/api/infra/market/data/bars/store"; readonly STORE_INDICATORS: "/api/infra/market/data/indicators/store"; readonly HEALTH: "/api/infra/market/health"; }; readonly ML: { readonly MODELS: "/api/infra/ml/models"; readonly MODELS_REGISTER: "/api/infra/ml/models/register"; readonly MODELS_PERFORMANCE: "/api/infra/ml/models/performance"; readonly MODEL_METRICS: "/api/infra/ml/models/:id/metrics"; readonly MODEL_DEPLOY: "/api/infra/ml/models/:id/deploy"; readonly SIGNALS_STORE: "/api/infra/ml/signals/store"; readonly SIGNALS_LATEST: "/api/infra/ml/signals/latest"; readonly SIGNALS_HISTORY: "/api/infra/ml/signals/history"; readonly SIGNALS_STREAM: "/api/infra/ml/signals/stream"; readonly CONSENSUS_STORE: "/api/infra/ml/consensus/store"; readonly CONSENSUS_LATEST: "/api/infra/ml/consensus/latest"; readonly CONSENSUS_HISTORY: "/api/infra/ml/consensus/history"; readonly FEATURES_LATEST: "/api/infra/ml/features/latest"; readonly FEATURES_STORE: "/api/infra/ml/features/store"; readonly ENSEMBLE_WEIGHTS: "/api/infra/ml/ensemble/weights"; readonly ENSEMBLE_UPDATE: "/api/infra/ml/ensemble/update"; readonly PERFORMANCE: "/api/infra/ml/performance"; readonly ANALYTICS: "/api/infra/ml/analytics"; readonly HEALTH: "/api/infra/ml/health"; }; readonly TRADING: { readonly ACCOUNTS: "/api/infra/trading/accounts"; readonly ACCOUNTS_SYNC: "/api/infra/trading/accounts/sync"; readonly POSITIONS: "/api/infra/trading/positions"; readonly POSITIONS_OPEN: "/api/infra/trading/positions/open"; readonly POSITIONS_CLOSE: "/api/infra/trading/positions/close"; readonly POSITIONS_HISTORY: "/api/infra/trading/positions/history"; readonly TRADES: "/api/infra/trading/trades"; readonly TRADES_RECENT: "/api/infra/trading/trades/recent"; readonly ORDERS: "/api/infra/trading/orders"; readonly ORDERS_PENDING: "/api/infra/trading/orders/pending"; readonly HEALTH: "/api/infra/trading/health"; }; readonly JOBS: { readonly CREATE: "/api/infra/jobs"; readonly LIST: "/api/infra/jobs/recent"; readonly GET: "/api/infra/jobs/:id"; readonly UPDATE: "/api/infra/jobs/:id"; readonly CANCEL: "/api/infra/jobs/:id/cancel"; readonly LOGS: "/api/infra/jobs/:id/logs"; readonly CLAIM: "/api/infra/jobs/claim"; readonly HEARTBEAT: "/api/infra/jobs/:id/heartbeat"; readonly TRIGGER: "/api/infra/jobs/trigger"; }; readonly WEALTH: { readonly HL: "/api/infra/wealth/hl"; readonly SUMMARY: "/api/infra/wealth/summary"; readonly ACCOUNTS: "/api/infra/wealth/accounts"; readonly SYNC: "/api/infra/wealth/sync"; }; readonly REALTIME: { readonly POSITIONS: "/api/infra/realtime/positions"; readonly SIGNALS: "/api/infra/realtime/signals"; readonly JOBS: "/api/infra/realtime/jobs/:id"; readonly PRICES: "/api/infra/realtime/prices"; }; readonly MARKETPLACE: { readonly VENDORS: "/api/infra/marketplace/vendors"; readonly VENDORS_REGISTER: "/api/infra/marketplace/vendors/register"; readonly VENDORS_PROFILE: "/api/infra/marketplace/vendors/profile"; readonly MODELS: "/api/infra/marketplace/models"; readonly MODELS_CATALOG: "/api/infra/marketplace/models/catalog"; readonly MODELS_SUBMIT: "/api/infra/marketplace/models/submit"; readonly DEPLOYMENTS: "/api/infra/marketplace/deployments"; readonly DEPLOYMENTS_CREATE: "/api/infra/marketplace/deployments/create"; readonly DEPLOYMENTS_HEALTH: "/api/infra/marketplace/deployments/health"; readonly AUTH_API_KEYS: "/api/infra/marketplace/auth/api-keys"; readonly AUTH_REGISTER: "/api/infra/marketplace/auth/register"; readonly TRAINING_JOBS: "/api/infra/marketplace/training/jobs"; readonly TRAINING_SUBMIT: "/api/infra/marketplace/training/submit"; readonly BILLING: "/api/infra/marketplace/billing"; readonly REVENUE_TRACKING: "/api/infra/marketplace/revenue/tracking"; readonly ANALYTICS_PERFORMANCE: "/api/infra/marketplace/analytics/performance"; readonly ANALYTICS_USAGE: "/api/infra/marketplace/analytics/usage"; }; readonly SYSTEM: { readonly HEALTH: "/api/infra/health"; readonly STATUS: "/api/infra/status"; readonly METRICS: "/api/infra/metrics"; readonly VERSION: "/api/infra/version"; }; }; declare const LEGACY_ROUTES: { readonly PORTFOLIO: { readonly SUMMARY: "/api/portfolio/summary"; readonly INVESTMENTS: "/api/portfolio/investments"; readonly VALUE: "/api/portfolio/value"; readonly HOLDINGS: "/api/portfolio/holdings"; readonly ACCOUNTS: "/api/portfolio/accounts"; readonly MANUAL_LIST: "/api/portfolio/manual/list"; readonly MANUAL_ADD: "/api/portfolio/manual/add"; }; readonly MARKET: { readonly OHLCV: "/api/marketdata/ohlcv"; readonly INDICATORS: "/api/marketdata/indicators"; readonly SYMBOLS: "/api/marketdata/symbols"; }; readonly ML: { readonly SIGNALS_STORE: "/api/signals/store"; readonly SIGNALS_LATEST: "/api/signals/latest"; readonly MODELS: "/api/models"; readonly CONSENSUS_LATEST: "/api/consensus/latest"; readonly BACKTEST: "/api/ml/backtest"; readonly PREDICT: "/api/ml/predict"; }; readonly TRADING: { readonly POSITIONS: "/api/trading/positions"; readonly TRADES: "/api/trading/trades"; readonly ACCOUNTS: "/api/trading/accounts"; readonly TRADES_OPEN: "/api/trading/trades/open"; readonly TRADES_CLOSED: "/api/trading/trades/closed"; readonly HISTORY: "/api/trading/history"; readonly ORDERS: "/api/trading/orders"; }; }; declare const ROUTES: { readonly AUTH: { readonly LOGIN: "/api/auth/login"; readonly LOGOUT: "/api/auth/logout"; readonly REFRESH: "/api/auth/refresh"; readonly VALIDATE: "/api/auth/validate"; readonly JWKS: "/api/auth/jwks"; readonly WHOAMI: "/api/auth/whoami"; readonly PERMISSIONS: "/api/auth/permissions"; readonly SESSION: "/api/auth/session"; readonly SESSION_VALIDATE: "/api/auth/session/validate"; readonly TOKEN_REFRESH: "/api/auth/token/refresh"; readonly LOGOUT_ALL: "/api/auth/logout/all"; }; readonly USER: { readonly PROFILE: "/api/user/profile"; readonly PREFERENCES: "/api/user/preferences"; readonly SESSIONS: "/api/user/sessions"; readonly ORGANIZATIONS: "/api/user/organizations"; readonly ROLES: "/api/user/roles"; readonly ACTIVITY: "/api/user/activity"; readonly SETTINGS: "/api/user/settings"; readonly NOTIFICATIONS: "/api/user/notifications"; }; readonly ADMIN: { readonly USERS: "/api/admin/users"; readonly ROLES: "/api/admin/roles"; readonly PERMISSIONS: "/api/admin/permissions"; readonly SYSTEM: "/api/admin/system"; readonly AUDIT: "/api/admin/audit"; readonly ORGANIZATIONS: "/api/admin/organizations"; readonly SECURITY: "/api/admin/security"; readonly MONITORING: "/api/admin/monitoring"; }; readonly INFRA: { readonly PORTFOLIO: { readonly SUMMARY: "/api/infra/portfolio/summary"; readonly ACCOUNTS: "/api/infra/portfolio/accounts"; readonly HOLDINGS: "/api/infra/portfolio/holdings"; readonly INVESTMENTS: "/api/infra/portfolio/investments"; readonly MANUAL_ADD: "/api/infra/portfolio/manual/add"; readonly SNAPSHOTS: "/api/infra/portfolio/snapshots"; readonly VALUE: "/api/infra/portfolio/value"; readonly SYNC: "/api/infra/portfolio/sync"; }; readonly MARKET: { readonly OHLCV: "/api/infra/market/data/ohlcv"; readonly INDICATORS: "/api/infra/market/data/indicators"; readonly BARS: "/api/infra/market/data/bars"; readonly PRECOMPUTED: "/api/infra/market/data/precomputed"; readonly UNIVERSE: "/api/infra/market/meta/universe"; readonly TIMEFRAMES: "/api/infra/market/meta/timeframes"; readonly STATUS: "/api/infra/market/meta/status"; readonly PROVIDERS: "/api/infra/market/meta/providers"; readonly STORE_BARS: "/api/infra/market/data/bars/store"; readonly STORE_INDICATORS: "/api/infra/market/data/indicators/store"; readonly HEALTH: "/api/infra/market/health"; }; readonly ML: { readonly MODELS: "/api/infra/ml/models"; readonly MODELS_REGISTER: "/api/infra/ml/models/register"; readonly MODELS_PERFORMANCE: "/api/infra/ml/models/performance"; readonly MODEL_METRICS: "/api/infra/ml/models/:id/metrics"; readonly MODEL_DEPLOY: "/api/infra/ml/models/:id/deploy"; readonly SIGNALS_STORE: "/api/infra/ml/signals/store"; readonly SIGNALS_LATEST: "/api/infra/ml/signals/latest"; readonly SIGNALS_HISTORY: "/api/infra/ml/signals/history"; readonly SIGNALS_STREAM: "/api/infra/ml/signals/stream"; readonly CONSENSUS_STORE: "/api/infra/ml/consensus/store"; readonly CONSENSUS_LATEST: "/api/infra/ml/consensus/latest"; readonly CONSENSUS_HISTORY: "/api/infra/ml/consensus/history"; readonly FEATURES_LATEST: "/api/infra/ml/features/latest"; readonly FEATURES_STORE: "/api/infra/ml/features/store"; readonly ENSEMBLE_WEIGHTS: "/api/infra/ml/ensemble/weights"; readonly ENSEMBLE_UPDATE: "/api/infra/ml/ensemble/update"; readonly PERFORMANCE: "/api/infra/ml/performance"; readonly ANALYTICS: "/api/infra/ml/analytics"; readonly HEALTH: "/api/infra/ml/health"; }; readonly TRADING: { readonly ACCOUNTS: "/api/infra/trading/accounts"; readonly ACCOUNTS_SYNC: "/api/infra/trading/accounts/sync"; readonly POSITIONS: "/api/infra/trading/positions"; readonly POSITIONS_OPEN: "/api/infra/trading/positions/open"; readonly POSITIONS_CLOSE: "/api/infra/trading/positions/close"; readonly POSITIONS_HISTORY: "/api/infra/trading/positions/history"; readonly TRADES: "/api/infra/trading/trades"; readonly TRADES_RECENT: "/api/infra/trading/trades/recent"; readonly ORDERS: "/api/infra/trading/orders"; readonly ORDERS_PENDING: "/api/infra/trading/orders/pending"; readonly HEALTH: "/api/infra/trading/health"; }; readonly JOBS: { readonly CREATE: "/api/infra/jobs"; readonly LIST: "/api/infra/jobs/recent"; readonly GET: "/api/infra/jobs/:id"; readonly UPDATE: "/api/infra/jobs/:id"; readonly CANCEL: "/api/infra/jobs/:id/cancel"; readonly LOGS: "/api/infra/jobs/:id/logs"; readonly CLAIM: "/api/infra/jobs/claim"; readonly HEARTBEAT: "/api/infra/jobs/:id/heartbeat"; readonly TRIGGER: "/api/infra/jobs/trigger"; }; readonly WEALTH: { readonly HL: "/api/infra/wealth/hl"; readonly SUMMARY: "/api/infra/wealth/summary"; readonly ACCOUNTS: "/api/infra/wealth/accounts"; readonly SYNC: "/api/infra/wealth/sync"; }; readonly REALTIME: { readonly POSITIONS: "/api/infra/realtime/positions"; readonly SIGNALS: "/api/infra/realtime/signals"; readonly JOBS: "/api/infra/realtime/jobs/:id"; readonly PRICES: "/api/infra/realtime/prices"; }; readonly MARKETPLACE: { readonly VENDORS: "/api/infra/marketplace/vendors"; readonly VENDORS_REGISTER: "/api/infra/marketplace/vendors/register"; readonly VENDORS_PROFILE: "/api/infra/marketplace/vendors/profile"; readonly MODELS: "/api/infra/marketplace/models"; readonly MODELS_CATALOG: "/api/infra/marketplace/models/catalog"; readonly MODELS_SUBMIT: "/api/infra/marketplace/models/submit"; readonly DEPLOYMENTS: "/api/infra/marketplace/deployments"; readonly DEPLOYMENTS_CREATE: "/api/infra/marketplace/deployments/create"; readonly DEPLOYMENTS_HEALTH: "/api/infra/marketplace/deployments/health"; readonly AUTH_API_KEYS: "/api/infra/marketplace/auth/api-keys"; readonly AUTH_REGISTER: "/api/infra/marketplace/auth/register"; readonly TRAINING_JOBS: "/api/infra/marketplace/training/jobs"; readonly TRAINING_SUBMIT: "/api/infra/marketplace/training/submit"; readonly BILLING: "/api/infra/marketplace/billing"; readonly REVENUE_TRACKING: "/api/infra/marketplace/revenue/tracking"; readonly ANALYTICS_PERFORMANCE: "/api/infra/marketplace/analytics/performance"; readonly ANALYTICS_USAGE: "/api/infra/marketplace/analytics/usage"; }; readonly SYSTEM: { readonly HEALTH: "/api/infra/health"; readonly STATUS: "/api/infra/status"; readonly METRICS: "/api/infra/metrics"; readonly VERSION: "/api/infra/version"; }; }; readonly PORTFOLIO: { readonly SUMMARY: "/api/portfolio/summary"; readonly INVESTMENTS: "/api/portfolio/investments"; readonly VALUE: "/api/portfolio/value"; readonly HOLDINGS: "/api/portfolio/holdings"; readonly ACCOUNTS: "/api/portfolio/accounts"; readonly MANUAL_LIST: "/api/portfolio/manual/list"; readonly MANUAL_ADD: "/api/portfolio/manual/add"; }; readonly MARKET: { readonly OHLCV: "/api/marketdata/ohlcv"; readonly INDICATORS: "/api/marketdata/indicators"; readonly SYMBOLS: "/api/marketdata/symbols"; }; readonly ML: { readonly SIGNALS_STORE: "/api/signals/store"; readonly SIGNALS_LATEST: "/api/signals/latest"; readonly MODELS: "/api/models"; readonly CONSENSUS_LATEST: "/api/consensus/latest"; readonly BACKTEST: "/api/ml/backtest"; readonly PREDICT: "/api/ml/predict"; }; readonly TRADING: { readonly POSITIONS: "/api/trading/positions"; readonly TRADES: "/api/trading/trades"; readonly ACCOUNTS: "/api/trading/accounts"; readonly TRADES_OPEN: "/api/trading/trades/open"; readonly TRADES_CLOSED: "/api/trading/trades/closed"; readonly HISTORY: "/api/trading/history"; readonly ORDERS: "/api/trading/orders"; }; }; /** * @fileoverview Authentication Domain - Modern Supabase Auth with JWKS * v0.18.0 Enhancement: Publishable/Secret key pattern with JWKS validation * Purpose: Modern Supabase auth, JWT validation, role-based access control */ declare const SupabaseAuthResponse: z.ZodObject<{ success: z.ZodLiteral; data: z.ZodObject<{ user: z.ZodObject<{ id: z.ZodString; email: z.ZodString; phone: z.ZodOptional; created_at: z.ZodString; updated_at: z.ZodString; last_sign_in_at: z.ZodOptional; app_metadata: z.ZodObject<{ provider: z.ZodString; providers: z.ZodArray; }, "strict", z.ZodTypeAny, { provider: string; providers: string[]; }, { provider: string; providers: string[]; }>; user_metadata: z.ZodObject<{ app_role: z.ZodOptional>; permissions: z.ZodOptional>; organization_id: z.ZodOptional; }, "strict", z.ZodTypeAny, { app_role?: "owner" | "admin" | "ml_developer" | "client" | undefined; permissions?: string[] | undefined; organization_id?: string | undefined; }, { app_role?: "owner" | "admin" | "ml_developer" | "client" | undefined; permissions?: string[] | undefined; organization_id?: string | undefined; }>; }, "strict", z.ZodTypeAny, { id: string; created_at: string; updated_at: string; email: string; app_metadata: { provider: string; providers: string[]; }; user_metadata: { app_role?: "owner" | "admin" | "ml_developer" | "client" | undefined; permissions?: string[] | undefined; organization_id?: string | undefined; }; phone?: string | undefined; last_sign_in_at?: string | undefined; }, { id: string; created_at: string; updated_at: string; email: string; app_metadata: { provider: string; providers: string[]; }; user_metadata: { app_role?: "owner" | "admin" | "ml_developer" | "client" | undefined; permissions?: string[] | undefined; organization_id?: string | undefined; }; phone?: string | undefined; last_sign_in_at?: string | undefined; }>; session: z.ZodObject<{ access_token: z.ZodString; refresh_token: z.ZodString; expires_in: z.ZodNumber; expires_at: z.ZodNumber; token_type: z.ZodLiteral<"bearer">; user: z.ZodObject<{ id: z.ZodString; email: z.ZodString; }, "strict", z.ZodTypeAny, { id: string; email: string; }, { id: string; email: string; }>; }, "strict", z.ZodTypeAny, { user: { id: string; email: string; }; expires_at: number; access_token: string; refresh_token: string; expires_in: number; token_type: "bearer"; }, { user: { id: string; email: string; }; expires_at: number; access_token: string; refresh_token: string; expires_in: number; token_type: "bearer"; }>; }, "strict", z.ZodTypeAny, { user: { id: string; created_at: string; updated_at: string; email: string; app_metadata: { provider: string; providers: string[]; }; user_metadata: { app_role?: "owner" | "admin" | "ml_developer" | "client" | undefined; permissions?: string[] | undefined; organization_id?: string | undefined; }; phone?: string | undefined; last_sign_in_at?: string | undefined; }; session: { user: { id: string; email: string; }; expires_at: number; access_token: string; refresh_token: string; expires_in: number; token_type: "bearer"; }; }, { user: { id: string; created_at: string; updated_at: string; email: string; app_metadata: { provider: string; providers: string[]; }; user_metadata: { app_role?: "owner" | "admin" | "ml_developer" | "client" | undefined; permissions?: string[] | undefined; organization_id?: string | undefined; }; phone?: string | undefined; last_sign_in_at?: string | undefined; }; session: { user: { id: string; email: string; }; expires_at: number; access_token: string; refresh_token: string; expires_in: number; token_type: "bearer"; }; }>; requestId: z.ZodString; timestamp: z.ZodString; }, "strict", z.ZodTypeAny, { data: { user: { id: string; created_at: string; updated_at: string; email: string; app_metadata: { provider: string; providers: string[]; }; user_metadata: { app_role?: "owner" | "admin" | "ml_developer" | "client" | undefined; permissions?: string[] | undefined; organization_id?: string | undefined; }; phone?: string | undefined; last_sign_in_at?: string | undefined; }; session: { user: { id: string; email: string; }; expires_at: number; access_token: string; refresh_token: string; expires_in: number; token_type: "bearer"; }; }; timestamp: string; success: true; requestId: string; }, { data: { user: { id: string; created_at: string; updated_at: string; email: string; app_metadata: { provider: string; providers: string[]; }; user_metadata: { app_role?: "owner" | "admin" | "ml_developer" | "client" | undefined; permissions?: string[] | undefined; organization_id?: string | undefined; }; phone?: string | undefined; last_sign_in_at?: string | undefined; }; session: { user: { id: string; email: string; }; expires_at: number; access_token: string; refresh_token: string; expires_in: number; token_type: "bearer"; }; }; timestamp: string; success: true; requestId: string; }>; declare const UserAuthResponse: z.ZodObject<{ success: z.ZodLiteral; data: z.ZodObject<{ user: z.ZodObject<{ id: z.ZodString; email: z.ZodString; roles: z.ZodArray, "many">; permissions: z.ZodArray; }, "strict", z.ZodTypeAny, { id: string; email: string; permissions: string[]; roles: ("owner" | "admin" | "ml_developer" | "client")[]; }, { id: string; email: string; permissions: string[]; roles: ("owner" | "admin" | "ml_developer" | "client")[]; }>; session: z.ZodObject<{ expires_at: z.ZodNumber; token_type: z.ZodLiteral<"Bearer">; access_token: z.ZodString; refresh_token: z.ZodOptional; }, "strict", z.ZodTypeAny, { expires_at: number; access_token: string; token_type: "Bearer"; refresh_token?: string | undefined; }, { expires_at: number; access_token: string; token_type: "Bearer"; refresh_token?: string | undefined; }>; }, "strict", z.ZodTypeAny, { user: { id: string; email: string; permissions: string[]; roles: ("owner" | "admin" | "ml_developer" | "client")[]; }; session: { expires_at: number; access_token: string; token_type: "Bearer"; refresh_token?: string | undefined; }; }, { user: { id: string; email: string; permissions: string[]; roles: ("owner" | "admin" | "ml_developer" | "client")[]; }; session: { expires_at: number; access_token: string; token_type: "Bearer"; refresh_token?: string | undefined; }; }>; requestId: z.ZodString; timestamp: z.ZodString; }, "strict", z.ZodTypeAny, { data: { user: { id: string; email: string; permissions: string[]; roles: ("owner" | "admin" | "ml_developer" | "client")[]; }; session: { expires_at: number; access_token: string; token_type: "Bearer"; refresh_token?: string | undefined; }; }; timestamp: string; success: true; requestId: string; }, { data: { user: { id: string; email: string; permissions: string[]; roles: ("owner" | "admin" | "ml_developer" | "client")[]; }; session: { expires_at: number; access_token: string; token_type: "Bearer"; refresh_token?: string | undefined; }; }; timestamp: string; success: true; requestId: string; }>; declare const SessionEnvelope: z.ZodObject<{ status: z.ZodLiteral<"ok">; user: z.ZodObject<{ id: z.ZodString; email: z.ZodNullable; roles: z.ZodOptional, "many">>; permissions: z.ZodOptional>; }, "strict", z.ZodTypeAny, { id: string; email: string | null; permissions?: string[] | undefined; roles?: ("owner" | "admin" | "ml_developer" | "client")[] | undefined; }, { id: string; email: string | null; permissions?: string[] | undefined; roles?: ("owner" | "admin" | "ml_developer" | "client")[] | undefined; }>; }, "strict", z.ZodTypeAny, { status: "ok"; user: { id: string; email: string | null; permissions?: string[] | undefined; roles?: ("owner" | "admin" | "ml_developer" | "client")[] | undefined; }; }, { status: "ok"; user: { id: string; email: string | null; permissions?: string[] | undefined; roles?: ("owner" | "admin" | "ml_developer" | "client")[] | undefined; }; }>; declare const UserEnvelope: z.ZodObject<{ status: z.ZodLiteral<"ok">; data: z.ZodAny; meta: z.ZodOptional>; }, "strict", z.ZodTypeAny, { status: "ok"; data?: any; meta?: Record | undefined; }, { status: "ok"; data?: any; meta?: Record | undefined; }>; declare const AuthResponse: z.ZodObject<{ status: z.ZodLiteral<"ok">; data: z.ZodAny; message: z.ZodOptional; }, "strict", z.ZodTypeAny, { status: "ok"; data?: any; message?: string | undefined; }, { status: "ok"; data?: any; message?: string | undefined; }>; /** * @fileoverview v0.18.0 Enhanced Schema Index - Infrastructure Aligned * Complete transformation with Infrastructure audit findings integrated * New: Auth, Jobs, Real-time, Enhanced schemas, Canonical /api/infra/* routes */ declare const SCHEMA_VERSION: "1.1.0"; declare const RELEASE_DATE: "2025-10-12"; declare const INFRASTRUCTURE_ALIGNMENT: { readonly database_migrations_included: readonly ["20250910000001_add_missing_v017_columns.sql", "20250916000004_fix_v017_schema.sql", "20250916000005_market_data_system.sql", "20250916000006_add_v017_portfolio_fields.sql", "20250916000007_jobs_system_minimal.sql"]; readonly new_tables_supported: readonly ["trading.accounts", "market.universe", "market.timeframes", "market.ingestion_status", "market.bars", "market.indicators", "jobs.jobs", "jobs.job_runs", "jobs.job_run_logs"]; readonly canonical_routes: "/api/infra/*"; readonly legacy_support_until: "v0.20.0"; }; /** * Contracts Version and Fingerprint * * The fingerprint is a SHA256 hash of all schema files in v0_18_0 * and is used to detect schema drift and ensure SSOT compliance. */ declare const CONTRACTS_VERSION = "0.19.1"; declare const CONTRACTS_FINGERPRINT = "0.19.1:fff38a6da619fbc648368b655694138563c73124d49105f725c5d23959bca7ac"; /** * @fileoverview Standard API Envelope Schemas * @description Standardized response envelope schemas for all API endpoints * @version 0.18.4 */ /** * Standard API response envelope schema * Used by all endpoints to provide consistent response format */ declare const ApiEnvelopeSchema: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodOptional; error: z.ZodOptional>; timestamp: z.ZodString; }, "strict", z.ZodTypeAny, { code: string; message: string; timestamp: string; details?: Record | undefined; }, { code: string; message: string; timestamp: string; details?: Record | undefined; }>>; meta: z.ZodOptional>; }, "strict", z.ZodTypeAny, { success: boolean; data?: any; error?: { code: string; message: string; timestamp: string; details?: Record | undefined; } | undefined; meta?: Record | undefined; }, { success: boolean; data?: any; error?: { code: string; message: string; timestamp: string; details?: Record | undefined; } | undefined; meta?: Record | undefined; }>; type ApiEnvelope = z.infer & { data?: T; }; /** * @fileoverview Standard HTTP Headers for API Endpoints * @description Required headers for all API responses * @version 0.18.4 */ /** * Standard headers that must be included in all API responses */ declare const STANDARD_HEADERS: { readonly 'X-Contracts-Version': "0.18.4"; readonly 'Content-Type': "application/json"; }; /** * @neuronetiq/contracts v0.18.0 - Infrastructure-Aligned Enhanced Contracts * * 🎯 INFRASTRUCTURE AUDIT INTEGRATION: All database changes since v0.17.0 included * 🔐 Enhanced Auth: Modern Supabase auth with JWKS validation * 🏗️ Jobs System: Unified async task orchestration for all teams * 📡 Real-time: WebSocket/SSE streaming endpoints * 🔗 Canonical Routes: /api/infra/* standardization with legacy compatibility * * Teams use enhanced imports: * - Auth: SupabaseJWTClaims, RoleDefinition, TokenValidation (JWKS-based) * - Portfolio: ManualInvestment (enhanced: exchange, account_type) * - Market: MarketUniverse, IngestionStatus, PrecomputedIndicators * - ML: Signal (enhanced: ta_fingerprint, bar_id confirmed in DB) * - Trading: TradingAccount (enhanced: new account types) * - Jobs: Job, CreateJobRequest (unified system) * - Routes: ROUTES.INFRA.* (canonical), ROUTES.* (legacy compatibility) */ declare const successEnvelope: (data: T, requestId: string, options?: { traceId?: string; latencyMs?: number; source?: string; deprecation?: Record; }) => { success: true; data: T; requestId: string; timestamp: string; meta: { contractsVersion: string; traceId: string | undefined; latencyMs: number | undefined; source: string; deprecation: Record | undefined; }; }; declare const errorEnvelope: (code: string, message: string, requestId: string, details?: Record, options?: { traceId?: string; latencyMs?: number; source?: string; }) => { success: false; error: { code: string; message: string; details: Record | undefined; timestamp: string; }; requestId: string; meta: { contractsVersion: string; traceId: string | undefined; latencyMs: number | undefined; source: string; }; }; declare const generateRequestId: () => string; declare const emitContractHeaders: () => { 'X-Contracts-Version': string; 'X-Contracts-Fingerprint': string; }; /** * @fileoverview @neuronetiq/contracts SDK - Canonical Public API Surface * @description Unified exports for Frontend, Infra, and ML teams * @version 0.18.4 */ declare const CONTRACTS_SDK_VERSION = "0.18.4"; export { ADMIN_ROUTES, AUTH_ROUTES, type ApiEnvelope, AuthResponse, CONTRACTS_FINGERPRINT, CONTRACTS_SDK_VERSION, CONTRACTS_VERSION, EnvelopeValidationError, INFRASTRUCTURE_ALIGNMENT, INFRA_ROUTES, LEGACY_ROUTES, PayloadValidationError, RELEASE_DATE, ROUTES, ROUTE_REGISTRY_METADATA, type RouteDefinition, RoutePaths, RouteRegistry, RouteValidationError, SCHEMA_VERSION, STANDARD_HEADERS, SessionEnvelope, SupabaseAuthResponse, TypeGuardError, USER_ROUTES, UserAuthResponse, UserEnvelope, ValidationError, assertValidRequest, assertValidResponse, assertValidResponseData, combineGuards, combineGuardsOr, createArrayGuard, createOptionalGuard, createSafeTypeGuard, createStrictTypeGuard, createTypeGuard, emitContractHeaders, errorEnvelope, generateRequestId, getActiveRoutes, getDeprecatedRoutes, getRouteInfo, getRoutesByMethod, safeValidateEnvelope, safeValidatePayload, successEnvelope, validateEnhancedEnvelope, validateEnvelope, validateEnhancedEnvelope as validateEnvelopeEnhanced, validateErrorEnvelope, validatePayload, validateRouteRequest, validateRouteResponse, validateStandardEnvelope };