repo
stringclasses
20 values
path
stringlengths
6
94
lang
stringclasses
5 values
n_chars
int64
81
200k
sha256
stringlengths
64
64
content
stringlengths
81
200k
eren23/non_linear_ai_chat
backend/src/config/__tests__/pricing.crossvalidation.test.ts
ts
24,421
3910f97d89e5bac4f545668e826e0f29db63e0a1f1ebe8e550c833829727018f
/** * Pricing Cross-Validation Tests * * Phase 4: Logic and accuracy tests that cross-validate pricing functions * against known values, verify the resolution priority chain, and ensure * markup, video, and embedding cost calculations are arithmetically correct. * * Tests cover: * - calculateCost with known mod...
eren23/non_linear_ai_chat
backend/src/config/__tests__/pricing.test.ts
ts
12,659
60a6ad1a65ba39d4e2d69817e5f6bcfcd3758c5e96e952468389bad4ca794283
import { describe, it, expect, vi, afterEach } from 'vitest'; import { getModelPricing, getEmbeddingPricing, getImageGenerationPricing, calculateCost, calculateEmbeddingCost, MODEL_PRICING, EMBEDDING_PRICING, IMAGE_GENERATION_PRICING, VIDEO_GENERATION_PRICING, estimateVideoCost, getVideoTierLimits...
eren23/non_linear_ai_chat
backend/src/config/__tests__/pricingConsistency.test.ts
ts
4,761
87c82263f1644d93826b36aa0c1fc2cd6716bfdf6f0cf29bca4d16baf0c9b14a
/** * Pricing Consistency Tests * * Verifies no duplicate pricing tables exist outside config/pricing.ts * and that MARKUP_PERCENT is only defined in one place. */ import { describe, it, expect } from 'vitest'; import fs from 'fs'; import path from 'path'; const backendSrcDir = path.join(__dirname, '..', '..'); ...
eren23/non_linear_ai_chat
backend/src/config/__tests__/session.test.ts
ts
7,414
91a34a69689bc07280636233a8152d67a1e4126cbefde1799b9e90c5e3d0eb14
import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { validateSessionSecret, getSessionSecret, SessionSecretValidationError, _clearCachedSecret, } from '../session'; describe('validateSessionSecret', () => { // Store original value to restore after tests const originalSessionSecret...
eren23/non_linear_ai_chat
backend/src/config/__tests__/providerFamilies.test.ts
ts
2,826
ed2538eca0902071ba1799b9eb5c1f123d8d148db7cc608e301bf9eee947fbfa
import { describe, it, expect } from 'vitest'; import { resolveProviderFamily } from '../providerFamilies'; describe('resolveProviderFamily', () => { it('maps major US providers', () => { expect(resolveProviderFamily('openai/gpt-5.1-chat')).toBe('OpenAI'); expect(resolveProviderFamily('anthropic/claude-opus-...
eren23/non_linear_ai_chat
backend/src/config/__tests__/searchConfig.test.ts
ts
3,774
c3a474fdbb2573a49a8111ac899bd177a2f3c37559b646bf9b02c14c5d91df94
import { describe, it, expect } from 'vitest'; import { SEARCH_CONFIG } from '../searchConfig'; describe('SEARCH_CONFIG', () => { describe('shape and types', () => { it('should have a positive timeoutMs', () => { expect(SEARCH_CONFIG.timeoutMs).toBeGreaterThan(0); expect(typeof SEARCH_CONFIG.timeoutM...
eren23/non_linear_ai_chat
backend/src/config/telegram/schema.ts
ts
6,664
f74de3759edf3e7a22fd806c36c80de071541547240dcc0292287573bebc7d7b
/** * Telegram Bot Configuration Schema * * Zod schemas for validating all Telegram bot configuration. * All hardcoded values extracted to environment variables with defaults. */ import { z } from 'zod'; // ============================================================================= // Model Configuration Schem...
eren23/non_linear_ai_chat
backend/src/config/telegram/thresholds.ts
ts
5,593
0c5b34dfaf1ae225ce805f58a2a4af22f2ce1fd0954824757ad78b408fc9412c
/** * Telegram Bot Threshold Configuration * * All thresholds and limits used across Telegram services. * Centralized for easy tuning and consistent behavior. */ // ============================================================================= // Memory Search Thresholds (by context) // ===========================...
eren23/non_linear_ai_chat
backend/src/config/telegram/index.ts
ts
9,125
375ce6fd3832562ebe3ef828b1ef98a04b85835676f512da41eeed559fe427f6
/** * Telegram Bot Configuration * * Centralized configuration for all Telegram bot services. * Loads from environment variables with validated defaults. * * Environment Variables: * - TELEGRAM_CLASSIFIER_MODEL: Model for intent classification * - TELEGRAM_CLASSIFIER_TEMPERATURE: Temperature for classifier * -...
eren23/non_linear_ai_chat
backend/src/config/telegram/patterns.ts
ts
12,319
836fdcf00a95ce3834fff0c2639f303fc389cf8606aa8825f632f6a57ae9fa66
/** * Telegram Bot Pattern Configuration * * All regex patterns and phrase lists used for intent detection, * context classification, and message parsing. * * Extracted from intentClassifier.ts for centralized management. */ // ============================================================================= // Con...
eren23/non_linear_ai_chat
backend/src/contracts/auth.contract.ts
ts
8,826
4a2d0a29a97a11ac567320e3c729285cf1b3f0273b6c4a62e48197d8ed013402
/** * Authentication API Contract Definitions */ import { z } from 'zod'; import { defineContract, commonResponses, objectIdSchema, timestampFields } from './index'; // User document schema (safe for responses) const userSchema = z.object({ _id: objectIdSchema, email: z.string().email(), name: z.string(), p...
eren23/non_linear_ai_chat
backend/src/contracts/globalSearch.contract.ts
ts
2,366
fbd25f71ccff195a1bf1d0b717be39a9bf93b5158a0cc8288f7a18b9f7847698
/** * Global Search API Contract Definition * * GET /api/search/global — Unified search across all data sources. */ import { z } from 'zod'; import { defineContract, commonResponses } from './index'; import { globalSearchQuerySchema } from '../schemas/globalSearch'; // ── Response schemas ────────────────────────...
eren23/non_linear_ai_chat
backend/src/contracts/backgroundAgent.contract.ts
ts
5,697
72098e06cb4773d1a7d40d0ed238a1b100b691ea168a9420e60c6b779b425920
/** * Background Agent API Contract Definitions * * Defines the contract for all background agent task endpoints. * Background tasks run asynchronously with lower budgets than interactive sessions. */ import { z } from 'zod'; import { defineContract, commonResponses } from './index'; // ============ SCHEMAS ====...
eren23/non_linear_ai_chat
backend/src/contracts/cli.ts
ts
7,850
a76fc6f548eafa65e65604c4fb8e4e60c7dcec1b8416f94a7f1ee7c6da463013
#!/usr/bin/env node /** * Contract Testing CLI * * Run contract tests and generate OpenAPI specs. * * Usage: * npm run contracts:test - Run all contract tests * npm run contracts:openapi - Generate OpenAPI spec * npm run contracts:validate - Validate contracts against implementation ...
eren23/non_linear_ai_chat
backend/src/contracts/generate.contract.ts
ts
5,937
2a5422641959a468b574e8806e08f71eed6ce5bf5770274cf63d2e16ec7720bf
/** * Generate API Contract Definitions * * Defines the contract for the AI generation endpoints. */ import { z } from 'zod'; import { defineContract, commonResponses, objectIdSchema } from './index'; import { generateRequestSchema, messageSchema, contextConfigSchema } from '../schemas/generate'; // Token usage ...
eren23/non_linear_ai_chat
backend/src/contracts/flows.contract.ts
ts
6,092
dca3a57b266955802281459ef48fefbec3c13c6cff6a6f3cbb5d78944c57c446
/** * Flow API Contract Definitions * * Defines the contract for all flow-related endpoints. */ import { z } from 'zod'; import { defineContract, commonResponses, objectIdSchema, paginationQuerySchema, timestampFields } from './index'; // Re-export schemas from flows schema file for contract definitions import {...
eren23/non_linear_ai_chat
backend/src/contracts/openapi.ts
ts
15,667
c225d8eb48954b777d7a1fc85973c68dc568da6ded2d2754f26fc1069bdfc814
/** * OpenAPI Specification Generator from Zod Schemas * * Generates OpenAPI 3.1 specification from contract definitions. */ import { z, ZodType, ZodObject, ZodArray, ZodString, ZodNumber, ZodBoolean, ZodEnum, ZodLiteral, ZodOptional, ZodNullable, ZodUnion, ZodRecord, ZodDate, ZodAny, ZodDefault, ZodEffects, ZodD...
eren23/non_linear_ai_chat
backend/src/contracts/memories.contract.ts
ts
6,821
b39ead624a84e4444ee309b5b105b99b63136ea6627f1e631de96a81b7d769f1
/** * Memory API Contract Definitions */ import { z } from 'zod'; import { defineContract, commonResponses, objectIdSchema, paginationQuerySchema, timestampFields } from './index'; import { createMemorySchema, updateMemorySchema, memorySearchQuerySchema, memoryListQuerySchema, memoryIdParamSchema, } from '...
eren23/non_linear_ai_chat
backend/src/contracts/types-generator.ts
ts
18,559
de3046ddde56daf3d57d694cc3eae00e61bdfcd6454eb11cd74d466b79c2d1e7
/** * TypeScript Type Generator from Zod Schemas * * Generates clean TypeScript type definitions from contract definitions * that can be used by frontend clients. */ import { z, ZodType, ZodObject, ZodArray, ZodString, ZodNumber, ZodBoolean, ZodEnum, ZodLiteral, ZodOptional, ZodNullable, ZodUnion, ZodRecord, Zod...
eren23/non_linear_ai_chat
backend/src/contracts/index.ts
ts
7,492
549f83afcd86ce8e57026d2957b867f062c090e8740a42eb764b2e9c3edf745d
/** * API Contract Testing Framework * * This module provides utilities for defining and testing API contracts. * Contracts validate both request and response shapes against Zod schemas. */ import { z, ZodSchema, ZodType } from 'zod'; import express, { Request, Response, NextFunction, Router } from 'express'; /...
eren23/non_linear_ai_chat
backend/src/contracts/runner.ts
ts
12,572
c663d5c72786cca24b3e00638e9478d7e4a4aff9f3a330cb9ea02210d5f2b6c3
/** * Contract Test Runner * * Executes contract tests against the API to verify compliance. */ import { z } from 'zod'; import express, { Express, Request, Response } from 'express'; import request from 'supertest'; import { contractRegistry, ApiContract, ContractTestResult, validateContract, commo...
eren23/non_linear_ai_chat
backend/src/contracts/__tests__/contract.test.ts
ts
16,935
5862c16c40f053e159187219308215aa21a0a545aca74b57c670df42e37cd2b5
/** * Contract Tests for API Endpoints * * These tests verify that API endpoints comply with their defined contracts. * Run with: npm run test:contracts */ import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import express from 'express'; import request from 'supertest'; import { ObjectId } from ...
eren23/non_linear_ai_chat
backend/src/contracts/__tests__/integration.test.ts
ts
16,700
35023f4dd7966255c68d31c50f88865520a5e0ebb1e85a0dae6b6a131e4465b1
/** * Contract Integration Tests * * Tests that verify actual API responses match contract definitions. * These tests hit real endpoints and validate response schemas. */ import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'; import express, { Express, NextFunction, Request, Response } from 'exp...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/helpers.ts
ts
2,501
128d362f192b142ebab1797fe39f80824f5c1f5ae281906981d8614d17038736
import type { SendAndWaitResult, InlineButton } from './client/types'; import { testPrefix } from './config'; /** * Assert that at least one response contains the given text (case-insensitive). */ export function expectResponseContains(result: SendAndWaitResult, text: string): void { const lower = text.toLowerCase...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/input.d.ts
ts
227
7a7f5e617481eb52ba206500fc9d29d0f0067bfc8d6196556c66f10346bf0b81
declare module 'input' { const input: { text(prompt: string): Promise<string>; confirm(prompt: string): Promise<boolean>; select(prompt: string, choices: string[]): Promise<string>; }; export default input; }
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/config.ts
ts
1,430
b555e6f5ee3ef9ba835784532e6698a6ba98c334d4d2a90b1f4cb0a59dd48e31
import dotenv from 'dotenv'; import { resolve } from 'path'; // Load .env from backend root dotenv.config({ path: resolve(__dirname, '../../../.env') }); export const E2E_CONFIG = { /** Telegram API credentials (from my.telegram.org) */ apiId: parseInt(process.env.TELEGRAM_API_ID || '0', 10), apiHash: process.e...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/setup/healthCheck.ts
ts
599
8b79ec3c290d0c9aa6646dcf8d8875747fc8f6be33d7f42d136216eed0867c08
import { TelegramE2EClient } from '../client/telegramClient'; import { E2E_CONFIG } from '../config'; /** * Send "hello" to the bot and verify it responds within the health check timeout. * Returns true if the bot is responsive, false otherwise. */ export async function checkBotHealth(client: TelegramE2EClient): Pr...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/setup/cleanup.ts
ts
1,497
acbebe5792a20d6a6ac317cb90349702cd29c100feb645dea33ddb9d10a66bf8
import { TelegramE2EClient } from '../client/telegramClient'; const E2E_TAG = '[E2E-'; /** * Best-effort cleanup: show tasks, find E2E-tagged ones, mark them done. * This won't crash if it fails — it's advisory cleanup. */ export async function cleanupTestData(client: TelegramE2EClient): Promise<void> { try { ...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/scenarios/conversation.e2e.test.ts
ts
1,396
5c2878f5986dbdeed3559acb681ecff123b26960e99f4c4a7dfaa3885f932e7c
import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import { TelegramE2EClient } from '../client/telegramClient'; import { isE2EEnabled } from '../config'; import { checkBotHealth } from '../setup/healthCheck'; describe.skipIf(!isE2EEnabled())('Telegram E2E: Conversation', () => { let client: Telegra...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/scenarios/briefing.e2e.test.ts
ts
1,198
6b15bba73a78bac6f5a018f1d72fe0dd945ce3799f210a975afefeeb2e0da5df
import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import { TelegramE2EClient } from '../client/telegramClient'; import { isE2EEnabled } from '../config'; import { checkBotHealth } from '../setup/healthCheck'; describe.skipIf(!isE2EEnabled())('Telegram E2E: Briefing & Flows', () => { let client: Tel...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/scenarios/reminders.e2e.test.ts
ts
1,361
9a8c4cedbdf9faab158d0fb714392dbcbd1534f6cfaaa5efcb4e1798c5b6fc07
import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import { TelegramE2EClient } from '../client/telegramClient'; import { isE2EEnabled } from '../config'; import { checkBotHealth } from '../setup/healthCheck'; import { testName } from '../helpers'; describe.skipIf(!isE2EEnabled())('Telegram E2E: Remin...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/scenarios/multiStep.e2e.test.ts
ts
2,472
1a987ab97786559e763527057ab82a7ba226117e03675da4d59faa124170fa6e
import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import { TelegramE2EClient } from '../client/telegramClient'; import { isE2EEnabled } from '../config'; import { checkBotHealth } from '../setup/healthCheck'; import { expectResponseContains, expectHasInlineKeyboard, testName } from '../helpers'; desc...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/scenarios/tasks.e2e.test.ts
ts
2,010
3c225be71a656682feba887d388293c0ba0c03f7ff08fbaf2c28fc58bf5ff8ad
import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import { TelegramE2EClient } from '../client/telegramClient'; import { isE2EEnabled } from '../config'; import { checkBotHealth } from '../setup/healthCheck'; import { testName } from '../helpers'; describe.skipIf(!isE2EEnabled())('Telegram E2E: Tasks...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/client/types.ts
ts
1,186
f8c3ec950ac4574ccd2ba35dee6c8970e7e1e84d6f648f9977b5dc078e1532d4
/** A parsed inline keyboard button from a bot message */ export interface InlineButton { text: string; callbackData?: string; url?: string; } /** A single response message from the bot */ export interface BotResponse { text: string; messageId: number; inlineKeyboard: InlineButton[][]; wasEdited: boolean...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/client/sessionManager.ts
ts
1,100
071a9b79827636e1403edd1a5fe4ce5755b249a2a9deab5b1a483c2579c8d630
import { TelegramClient } from 'telegram'; import { StringSession } from 'telegram/sessions'; import input from 'input'; import { createLogger } from '../../../services/logger.js'; const log = createLogger('tests.telegram-e2e.client.sessionManager'); /** * Interactive auth flow — generates a GramJS session string. ...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/client/telegramClient.ts
ts
7,986
0e9abf20dcef0214b3480760f25aba0dea3aa38f74a2fbf8d087469ae8b837e5
import { TelegramClient } from 'telegram'; import { StringSession } from 'telegram/sessions'; import { NewMessage, NewMessageEvent } from 'telegram/events'; import { Api } from 'telegram'; import { E2E_CONFIG } from '../config'; import type { BotResponse, InlineButton, SendAndWaitResult } from './types'; interface Sen...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/probe/probe.ts
ts
1,823
92446ae0849e8ff1702e90d048ea6050f80e75e300e656e86a09ce79e423dd5e
import { TelegramE2EClient } from '../client/telegramClient'; import type { BotResponse, ProbeResult, SendAndWaitResult } from '../client/types'; let sharedClient: TelegramE2EClient | null = null; async function getClient(): Promise<TelegramE2EClient> { if (!sharedClient) { sharedClient = new TelegramE2EClient(...
eren23/non_linear_ai_chat
backend/src/tests/telegram-e2e/probe/run.ts
ts
3,200
515653e59ff8ef4a4ba4a00c8fe6a4a0abba05d72bc65f2ae5d9b7521d92381a
#!/usr/bin/env tsx /** * CLI entry point for the Telegram E2E probe. * * Usage: * npx tsx backend/src/tests/telegram-e2e/probe/run.ts "show my tasks" * npx tsx backend/src/tests/telegram-e2e/probe/run.ts --observe 5 * npx tsx backend/src/tests/telegram-e2e/probe/run.ts --press 12345 "Done" * * Output: JSO...
eren23/non_linear_ai_chat
backend/src/tests/fixtures/index.ts
ts
5,688
45bb79a17cae774240bdb52066917bff3e9a5d57fccc3b8932425b895af91a62
/** * Test fixtures - reusable test data generators */ import { ObjectId } from 'mongodb'; export interface TestUser { _id: string; email: string; name: string; tier: 'free' | 'pro' | 'enterprise'; isAdmin: boolean; defaultTemperature?: number; enabledTools?: string[]; agentMaxSteps?: number; agen...
eren23/non_linear_ai_chat
backend/src/tests/helpers/mocks.ts
ts
10,198
84fd118af7e76b46dc751bdebc59b419ec31014cb2fb5f53756e2c49e43c1754
/** * Mock helpers for testing */ import { vi, beforeEach, afterEach } from 'vitest'; import type { Request, Response, NextFunction } from 'express'; import type { TestUser } from '../fixtures'; /** * Create a mock Express request */ export function createMockRequest( overrides: Partial<Request> = {} ): Partial...
eren23/non_linear_ai_chat
backend/src/utils/fileTypeDetector.ts
ts
8,439
20e30eaa410f61944e1b9f72a5778dc8fe1a6882bf60f8a0593adbafae990e6c
import FileType from 'file-type'; import { createLogger } from '../services/logger.js'; const log = createLogger('utils.fileTypeDetector'); export interface FileTypeInfo { mime: string; ext: string; } // MIME types that don't have reliable magic bytes (text-based) const TEXT_BASED_MIMES = new Set([ 'text/plain...
eren23/non_linear_ai_chat
backend/src/utils/urlValidator.ts
ts
3,921
9581cdb96618efe861d5e5b5f1ae3698d829764ac6d31b9d057918744dd27cae
/** * URL Validation Utility for SSRF Protection * * Provides centralized validation for external URLs to prevent * Server-Side Request Forgery (SSRF) attacks. */ export interface UrlValidationResult { valid: boolean; reason?: string; } /** * List of blocked hostnames for SSRF protection. * Includes localh...
eren23/non_linear_ai_chat
backend/src/utils/sanitize.ts
ts
14,809
de8a00c2c672477f488912752cdba2b76c7d7db98929255aa2718e14faa75418
/** * Input sanitization and validation utilities. * Provides comprehensive sanitization for all user inputs. * * Shared pure functions (sanitizeString, sanitizeName, sanitizeDescription, * sanitizeTag, sanitizeTags, sanitizeRagQuery, sanitizeMessages, INPUT_LIMITS) * are re-exported from @spider-chat/shared. Bac...
eren23/non_linear_ai_chat
backend/src/utils/json.ts
ts
2,756
4214fde4d256b90a3398e7a5170fe19b6f63a44df7136cb7b923821e2731923e
/** * Utilities for deterministic JSON serialization. * Ensures consistent output for prompt caching optimization. */ /** * Recursively sort object keys to ensure deterministic JSON serialization. * This is critical for prompt caching - identical objects must produce identical strings. * * Enhanced to handle s...
eren23/non_linear_ai_chat
backend/src/utils/searchUtils.ts
ts
4,939
f1c9372095361e3de1ba7113b9c3781ba503e95d905371ebc4335f1c5bb4fe10
/** * Shared Search Utilities * * Common helpers used across search orchestrators (globalSearch, relatedContext). * Extracted to avoid duplication and ensure consistent behavior. */ import { createLogger } from '../services/logger.js'; const log = createLogger('searchUtils'); /** * Wrap a promise with a timeou...
eren23/non_linear_ai_chat
backend/src/utils/versioning.ts
ts
1,685
a9c87bfc5285256175e8863377527dbf650bcd1c73679e509790cdd7c413e207
/** * Version vector utilities for optimistic concurrency control. * * Used to prevent lost updates when multiple agents/clients modify flows concurrently. * Each update must include the current version; if it doesn't match, the update is rejected. */ export const VERSION_CONFLICT_ERROR = 'VERSION_CONFLICT'; /**...
eren23/non_linear_ai_chat
backend/src/utils/errorFormatting.ts
ts
4,678
bee0eea8a3a0691bca5729c733fc52924166aaac44b4a2407d0a3485d96dd151
/** * Error formatting utilities for Zod validation errors and tool errors. */ import { ZodError } from 'zod'; /** * Format Zod validation error for user-friendly display */ export function formatValidationError(error: ZodError, context?: string): string { const contextPrefix = context ? `${context}: ` : ''; ...
eren23/non_linear_ai_chat
backend/src/utils/redisScan.ts
ts
3,791
4b93c5c9fe4ccecee891c481b467f8e399cb50207e5139044f604ec4548b41cb
/** * Redis SCAN utility for production-safe key iteration. * * Replaces redis.keys() which blocks Redis with O(N) complexity. * SCAN is non-blocking and uses cursor-based iteration. */ import type Redis from 'ioredis'; import { createLogger } from '../services/logger.js'; const log = createLogger('utils.redis...
eren23/non_linear_ai_chat
backend/src/utils/retry.ts
ts
5,305
5ecb8777a44e5fec68ff2d2b4bdd454f15620eea57db4bfe157b5eb8fa90bdf0
import { createLogger } from '../services/logger.js'; /** * Retry Utility with Exponential Backoff * * Provides a generic retry mechanism for handling transient failures * in external service calls (LLM APIs, databases, etc.). */ export interface RetryOptions { /** Maximum number of retry attempts (default: 3) ...
eren23/non_linear_ai_chat
backend/src/utils/timezoneUtils.ts
ts
7,224
59a9106071d62688b572c530c07ea28735e119a1f4046c4303c246513fd57633
/** * Timezone Utilities * * Helper functions for timezone-aware date handling using date-fns-tz. * All dates stored in the database should be UTC; these utilities help * convert between user's local time and UTC. */ import { toZonedTime, fromZonedTime, formatInTimeZone } from 'date-fns-tz'; /** Default timezon...
eren23/non_linear_ai_chat
backend/src/utils/fireAndForget.ts
ts
3,230
ad612ed5eae36626b10035b3230ccd2d46eff8aed71395c1d4a5dde92e6fe061
/** * Fire-and-Forget Utility * * Handles background promises that shouldn't block the main flow but * should still have their errors logged for observability. * * Usage: * ```typescript * // Instead of: * someAsyncOp().catch(() => {}); * * // Use: * fireAndForget(someAsyncOp(), { service: 'memories', opera...
eren23/non_linear_ai_chat
backend/src/utils/backgroundTask.ts
ts
4,998
76a5f9bdc67523da773fc90edd2370a649f15806331081349cbc60b8e520ecec
/** * Background Task Utility * * Provides a wrapper for background tasks that: * 1. Retries on failure with exponential backoff * 2. Logs failures to the Dead Letter Queue after max retries * 3. Provides consistent error handling and observability * * Usage: * ```typescript * // Instead of: * extractMemorie...
eren23/non_linear_ai_chat
backend/src/utils/cacheOptimization.ts
ts
11,935
7917cabc900f162f961aafd00c2d7574d683c2c289e41b564ec141ba791179e9
/** * Cache optimization utilities for prompt caching. * Supports OpenRouter's cache_control for Anthropic and Gemini models. */ import { stringifyDeterministic } from './json'; import { createLogger } from '../services/logger.js'; /** * Message for LLM context. * Content can be a simple string or array of conte...
eren23/non_linear_ai_chat
backend/src/utils/tokens.ts
ts
6,509
ff691e5fef739d2ff30389a331dcd33a37af581c0b7a4168ffe22f760e3dfaa0
/** * Token counting utilities using tiktoken for accurate token estimation. */ import { encoding_for_model, get_encoding, Tiktoken } from 'tiktoken'; import type { Message } from './cacheOptimization'; import { createLogger } from '../services/logger.js'; const log = createLogger('utils.tokens'); // Multimodal co...
eren23/non_linear_ai_chat
backend/src/utils/apiResponse.ts
ts
6,900
541afdbd6218187c245b17154e7c14b9a92f69b4fca6729631d7e814e249ece2
/** * Unified API response utilities for consistent response formatting. * Eliminates duplicated res.status().json() patterns across route files. */ import { Response } from 'express'; import { ZodError } from 'zod'; import { formatValidationError } from './errorFormatting'; // ====================================...
eren23/non_linear_ai_chat
backend/src/utils/circuitBreaker.ts
ts
10,575
f75c871c0785a4432451ee695a10a9d1f7915848214d19e2c9bef3acada61c65
/** * Circuit Breaker Pattern Implementation * * Prevents cascading failures by temporarily blocking calls to a failing service. * After a timeout period, allows limited calls through to test if the service recovered. * * States: * - CLOSED: Normal operation, requests flow through * - OPEN: Service is failing, ...
eren23/non_linear_ai_chat
backend/src/utils/duration.ts
ts
5,490
fa933116804a298d5b157496e1411c8537b21f92f9273d9b6557f1ce2154b829
import { createLogger } from '../services/logger.js'; /** * Human-Readable Duration Parsing * * Converts duration strings like "7d", "30s", "2h" to milliseconds. * Eliminates magic numbers like 604800000 in config files. * * @example * ```typescript * parseDuration("7d") // 604800000 (7 days in ms) * parseD...
eren23/non_linear_ai_chat
backend/src/utils/dedupe.ts
ts
6,852
df639b5e7ad59b7873f53812839255f1cc3770b448b99c22dc8aad25533b88f9
import { createLogger } from '../services/logger.js'; /** * Deduplication Cache with TTL and LRU Eviction * * Generic cache for preventing duplicate processing of messages, requests, etc. * Uses Map with timestamps for O(1) operations and automatic cleanup. */ interface CacheEntry { timestamp: number; } export...
eren23/non_linear_ai_chat
backend/src/utils/errorMessages.ts
ts
7,815
0e6a9451f90920a7ff1b66a97ba0e250572b8d3c232a27830e3e4b00e2a70ea6
/** * Centralized Error Message Utility * * Transforms internal/technical errors into user-friendly messages. * Used across routes to ensure consistent error communication. */ /** * Error categories for pattern matching */ export enum ErrorCategory { MODEL_UNAVAILABLE = 'MODEL_UNAVAILABLE', RATE_LIMIT = 'RA...
eren23/non_linear_ai_chat
backend/src/utils/urlCanonicalizer.ts
ts
1,192
462686d3f0ee9fd327d62a4e08bddea3ba3c5ee6296c7ecde9c2977dc50b64e8
/** * Canonical URL normalizer for deduplication. * * Removes common tracking params and URL fragments, lowercases host, * and normalizes trailing slashes for non-root paths. */ const TRACKING_QUERY_PARAMS = new Set([ 'fbclid', 'gclid', 'igshid', 'mc_cid', 'mc_eid', 'mkt_tok', 'msclkid', 'ref', ...
eren23/non_linear_ai_chat
backend/src/utils/formatBytes.ts
ts
479
1c209c0b4f2db4dd508505d48fb5b65c59357496c4f7924b39c04e711f876334
/** * Format a byte count as a human-readable string. * Consolidated utility — import from here instead of defining locally. */ export function formatBytes(bytes: number, decimals = 2): string { if (bytes === 0) return '0 Bytes'; const k = 1024; const dm = decimals < 0 ? 0 : decimals; const sizes = ['Bytes',...
eren23/non_linear_ai_chat
backend/src/utils/dateParser.ts
ts
29,745
3c64c6fe0ef4be553fe89f0ce39a7a1aa1e53afb03e7fb3ec8771305a6edd839
/** * Shared Natural Language Date Parsing Utility * * Used by both Spider Chat memory extraction and Telegram intent classification * for consistent date parsing across platforms. * * TIMEZONE HANDLING: * - All returned dates are in UTC for storage * - Pass user's timezone to interpret "at 3pm" as 3pm in their...
eren23/non_linear_ai_chat
backend/src/utils/zodParsers.ts
ts
7,261
681454403a8cef98095985235cfcb04f588c8ae8092f8bfadef68f53a433f88f
/** * Zod parsing utilities with fallback strategies and error handling. */ import { z, ZodSchema, ZodError } from 'zod'; /** * Result type for parsing operations */ export type ParseResult<T> = | { success: true; data: T } | { success: false; error: ZodError }; /** * Parse data with a Zod schema, returning...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/circuitBreaker.test.ts
ts
11,176
78290b987ebfdff01dc71ccd27bde54996702b988d85d0513d071e8320720c8a
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { CircuitBreaker, CircuitState, getAllCircuitBreakerStatus, llmCircuitBreaker, ragCircuitBreaker, embeddingCircuitBreaker, } from '../circuitBreaker'; describe('CircuitBreaker', () => { let circuitBreaker: CircuitBreaker; ...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/errorFormatting.test.ts
ts
8,528
c1963ffc79403ee0be78d7a794f4f3772932041c24f04d8ba789e80bec55910f
import { describe, it, expect } from 'vitest'; import { ZodError } from 'zod'; import { formatValidationError, formatToolError, formatToolValidationError, createSSEError, formatErrorForTelemetry, isValidationError, getUserFriendlyErrorMessage, createDetailedError, } from '../errorFormatting'; describe(...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/sanitize.test.ts
ts
14,406
01d49c225ccd94cd577451b39bc4ea6aa7160917297854ff7ba1ef198e3aa025
import { describe, it, expect } from 'vitest'; import { sanitizeString, sanitizeMessage, sanitizeName, sanitizeFileName, sanitizeDescription, sanitizeTag, sanitizeTags, isValidObjectId, sanitizeFlowId, sanitizeNodeId, sanitizeMessages, INPUT_LIMITS, escapeRegex, stripAllHtml, } from '../sani...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/urlCanonicalizer.test.ts
ts
2,819
fb33af25a6647165eebca9cef1f73f70ad5248d6d643719ca7f040881e2e13b6
import { describe, it, expect } from 'vitest'; import { canonicalizeUrl } from '../urlCanonicalizer'; describe('canonicalizeUrl', () => { it('removes UTM tracking parameters', () => { expect(canonicalizeUrl('https://example.com/page?utm_source=twitter&utm_medium=social&utm_campaign=spring')) .toBe('https:/...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/retry.test.ts
ts
17,997
3075b61e672663f25f830154c87bb9cbcf6b1a1e0367da187fe54ddaaaa7d494
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { withRetry, isRetryableError, createRetryWrapper } from '../retry'; const { mockLogger } = vi.hoisted(() => ({ mockLogger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), }, })); vi.mock('../../servic...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/fireAndForget.test.ts
ts
9,946
b64bf400b51637d76dbc1a491323b155fb84e2ff467c6beaacfbba8c6209abfc
/** * Tests for fireAndForget utility. * * Covers: * - fireAndForget: logging errors, Sentry reporting, silent mode * - createServiceFireAndForget: scoped fire-and-forget for a service * - wrapFireAndForget: wrapping async functions for fire-and-forget execution */ import { describe, it, expect, vi, beforeEach ...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/dateParser.test.ts
ts
54,600
59f7a432fd78be4a292a4b5622f0b1f5853a571b01287f0b6dab09aafb02dcb6
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { parseNaturalDate, parseLLMDate, daysUntil, isWithinDays, classifyDueDate, parseTimeToDate, parseDateTimeExpression, extractReminderTime, } from '../dateParser'; // --------------------------------------------------------...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/sanitize-security.test.ts
ts
11,572
5cdff2e619fb26b64fb52c1fe2a50ad533f5c750f467bdc63b7813c5564d7cd0
import { describe, it, expect } from 'vitest'; import { sanitizeMessage, sanitizeFlowId, sanitizeNodeId, stripAllHtml, } from '../sanitize'; /** * Security-critical tests for sanitization utilities. * * The existing sanitize.test.ts covers basic functionality (null handling, * length limits, filename sanit...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/fileTypeDetector.test.ts
ts
4,320
29a653d5c012a678d32e2eb3ab868743580355443b2e77954f6cfabad62863d1
import { describe, it, expect } from 'vitest'; import { detectFileType, validateFileSignature, getAllowedMimeTypes, isAllowedMimeType } from '../fileTypeDetector'; describe('fileTypeDetector', () => { describe('detectFileType', () => { it('should detect PDF from magic bytes', async () => { // PDF starts wi...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/apiResponse.test.ts
ts
11,971
a2f78e082d0c393bb50ec1f649b092e5dc4cea8ae04b24c55ff7aba666f07c4d
import { describe, it, expect, vi, beforeEach } from 'vitest'; import { ZodError } from 'zod'; import { sendSuccess, sendWrappedSuccess, sendCreated, sendNoContent, sendError, sendSimpleError, sendBadRequest, sendUnauthorized, sendForbidden, sendNotFound, sendConflict, sendRateLimited, sendSer...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/versioning.test.ts
ts
8,456
fd37da17072c7ebcfa39f486b8b629ab32e540885cce23756e81afd6e900bd6d
import { describe, it, expect } from 'vitest'; import { isVersionValid, getNextVersion, createVersionConflictResponse, VERSION_CONFLICT_ERROR, } from '../versioning'; describe('VERSION_CONFLICT_ERROR constant', () => { it('should be the expected error code', () => { expect(VERSION_CONFLICT_ERROR).toBe('V...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/duration.test.ts
ts
12,295
2982f306bb086957c9f69b53c50252f548828319fc409238822bca168900bf65
import { describe, it, expect, vi, afterEach } from 'vitest'; import { parseDuration, parseDurationSafe, formatDuration, DURATION, } from '../duration'; const { mockLogger } = vi.hoisted(() => ({ mockLogger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), }, })); vi.mock('....
eren23/non_linear_ai_chat
backend/src/utils/__tests__/errorMessages.test.ts
ts
11,354
0c3a64b90f25efa84129a614462e0042cff9120b6d1f063e2ea0cd88f22d1ef1
import { describe, it, expect } from 'vitest'; import { ErrorCategory, categorizeError, toUserFriendlyError, toModelError, isRecoverableError, getRetryDelay, buildErrorResponse, } from '../errorMessages'; describe('categorizeError', () => { describe('MODEL_UNAVAILABLE', () => { it.each([ 'mod...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/zodParsers.test.ts
ts
9,495
07df58616af3431a7323e2630e945a89c63a5cff96841199964d8907186fd6f6
import { describe, it, expect } from 'vitest'; import { z } from 'zod'; import { parseWithSchema, parseWithFallback, extractAndParseJSON, extractAndParseJSONWithFallback, formatZodError, formatZodErrorForLLM, createValidationError, partialParse, validateWithCoercion, } from '../zodParsers'; const tes...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/timezoneUtils.test.ts
ts
16,004
9375fed21e86eb7605d5be7b6f2a7534945a494ccbdb2143a55090982163dd9f
/** * Tests for timezoneUtils - timezone-aware date handling helpers. * * Covers: * - localToUTC: converting local dates to UTC * - utcToLocal: converting UTC dates to local timezone * - formatInTimezone: formatting dates for display * - nowInTimezone: getting current time in a timezone * - formatCurrentTimeFor...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/redisScan.test.ts
ts
5,639
df6803965972bcfa99b21117877616633b76ff76d1a8940db94ff205057073ce
import { describe, it, expect, vi, beforeEach } from 'vitest'; import { scanKeys, collectKeys, countKeys, deleteKeysByPattern } from '../redisScan'; // Mock Redis client function createMockRedis(scanResults: Array<[string, string[]]>) { let callIndex = 0; return { scan: vi.fn().mockImplementation(() => { ...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/json.test.ts
ts
9,214
0a6c12c3cfc2c255e4fccce95ac9724e1893b6f803247dce3c48bba16c0fc4b5
import { describe, it, expect } from 'vitest'; import { stringifyDeterministic, deepEqual, hashValue } from '../json'; describe('stringifyDeterministic', () => { it('should sort object keys alphabetically', () => { const obj = { b: 1, a: 2, c: 3 }; const result = stringifyDeterministic(obj); expect(resul...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/dedupe.test.ts
ts
14,047
a0fb6ef0f012a99df81961a454ba464415c78dc5b352c8be0a78cef286564970
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { createDedupeCache, createContentDedupeCache } from '../dedupe'; describe('createDedupeCache', () => { beforeEach(() => { vi.useFakeTimers(); }); afterEach(() => { vi.useRealTimers(); }); describe('check()', () => { ...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/urlValidator.test.ts
ts
13,899
d9ccbe30866387fee7c7dfbe4c9920c0e5528e159c4f7122452dfe025fa5026d
import { describe, it, expect } from 'vitest'; import { validateExternalUrl, assertSafeExternalUrl } from '../urlValidator'; describe('validateExternalUrl', () => { describe('valid URLs', () => { it('should accept valid HTTPS URLs', () => { expect(validateExternalUrl('https://example.com')).toEqual({ valid...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/cacheOptimization.test.ts
ts
13,235
95b8a423d7d1acf0c294381442132a775bd3f28963f1f0fad0f97b7a1ecc7734
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { MAX_CACHE_BREAKPOINTS, withCacheControl, buildCacheOptimizedMessages, serializeForCache, wrapMessageWithCache, appendWithCache, hasCacheControl, getCacheStats, type CacheOptimizedMessage, type MessageContentPart, ty...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/backgroundTask.test.ts
ts
14,280
c4ba6d7cb6c3a0404f128f285fc035da0c943a8cd28ba69dfa6652d0d99e03ef
/** * Tests for backgroundTask utility. * * Covers: * - runBackgroundTask: retry logic, DLQ logging, Sentry reporting, error callbacks * - createBackgroundTaskRunner: scoped runner creation * - wrapAsBackgroundTask: wrapping async functions for background execution */ import { describe, it, expect, vi, beforeEa...
eren23/non_linear_ai_chat
backend/src/utils/__tests__/tokens.test.ts
ts
9,071
0c18e098b1b05f7e68c385bfb669ddacdbd0ba47631db0b357832d6b43668280
import { describe, it, expect, afterAll } from 'vitest'; import { countTokens, countMessageTokens, estimateToolCallOverhead, countToolResultTokens, estimateTokensSimple, normalizeModelName, cleanupEncoders, } from '../tokens'; afterAll(() => { cleanupEncoders(); }); describe('countTokens', () => { i...
eren23/non_linear_ai_chat
backend/src/schemas/note.ts
ts
2,246
65d1cfcb1772dc23be2f538f66e207e51e6656cf07ad8c32bbdef9f0b7c11526
/** * Zod schemas for note routes. */ import { z } from 'zod'; /** * Create note schema */ export const createNoteSchema = z.object({ title: z.string().min(1).max(200), content: z.string().max(50000), tags: z.array(z.string().max(50)).max(20).optional(), isPinned: z.boolean().optional(), pinnedToFlow: z...
eren23/non_linear_ai_chat
backend/src/schemas/localAuth.ts
ts
578
48d41ecf304ad04668ba834645ee47b1a2a21d9eed259b290294da4ca24991a9
/** * Zod schemas for local auth routes. */ import { z } from 'zod'; export const registerSchema = z.object({ email: z.string().email().max(320), name: z.string().trim().min(2).max(100), }); export const loginSchema = z.object({ email: z.string().email(), password: z.string().min(1), }); export const rese...
eren23/non_linear_ai_chat
backend/src/schemas/parallelGenerate.ts
ts
2,872
c8747bdac9e625547cbd96d6749af0aa3e2cecbf1ebad6eb8427df76ef0d0323
/** * Zod schemas for parallel generation endpoint. * * Supports three modes: * - branches: Generate N alternative responses with the same model * - models: Generate responses from different models in parallel * - synthesis: Generate from multiple models, then synthesize */ import { z } from 'zod'; /** * Mess...
eren23/non_linear_ai_chat
backend/src/schemas/unifiedMemory.ts
ts
2,595
5475e9f0edb41c77b920e393a45762dc40675c2986e63e6091bf6cf9c92c2bb5
import { z } from 'zod'; // Memory type classification export const memoryTypeSchema = z.enum([ 'task', 'fact_about_me', 'fact_about_other', 'learning', 'decision', 'context', 'transient', 'garbage', ]); export type MemoryType = z.infer<typeof memoryTypeSchema>; // Source interface export const source...
eren23/non_linear_ai_chat
backend/src/schemas/memories.ts
ts
4,125
0e4a11531d4ee98accb75f3efd4653a8cf22e0e317a2770d8a332c55200afcd2
/** * Zod schemas for memory routes. */ import { z } from 'zod'; /** * Memory type enum */ export const memoryTypeSchema = z.enum(['conversation', 'note', 'insight']); /** * Memory category enum */ export const memoryCategorySchema = z.enum([ 'personal_info', 'task_short_term', 'task_long_term', 'respo...
eren23/non_linear_ai_chat
backend/src/schemas/flows.ts
ts
11,092
c350974cad336706ef762628612c6f2fc5c08a4d8b525a59e6c776a2cb0de5f6
/** * Zod schemas for flow routes. */ import { z } from 'zod'; import { contextConfigSchema } from './generate'; /** * Grid position schema for grid-native layout. */ export const gridPositionSchema = z.object({ col: z.number().int().min(0), row: z.number().int().min(0), }); /** * Viewport schema */ export...
eren23/non_linear_ai_chat
backend/src/schemas/globalSearch.ts
ts
977
dc5412ceb09c4ce7e2bd888793fd4cf7653bad3bffa1f2bb4554b19eca6d4708
/** * Global Search Schema - Zod validation for unified search endpoint. */ import { z } from 'zod'; export const globalSearchQuerySchema = z.object({ query: z.string().min(1).max(500), limit: z.coerce.number().int().min(1).max(50).default(20), sourceTypes: z .string() .optional() .transform((val)...
eren23/non_linear_ai_chat
backend/src/schemas/capture.ts
ts
1,195
8116519af111e1e6bbd22354115a39c06eab45f1801f3f9d2372e5ea056668d6
/** * Zod schemas for capture routes. * * Validates payload for the unified capture endpoint that accepts * content from multiple sources (telegram, extension, mcp, chat, api). */ import { z } from 'zod'; /** * Source metadata schema for capture requests. * Contains optional source-specific information. */ ex...
eren23/non_linear_ai_chat
backend/src/schemas/tools.ts
ts
12,759
7af745c30e63e3a0a51339f8cdaec8d6325f9d73a351065bd3c859582132542a
/** * Zod schemas for tool system - strict validation for all tool inputs and outputs. */ import { z } from 'zod'; // ============================================================================ // Tool Argument Schemas // ============================================================================ /** * Web Sear...
eren23/non_linear_ai_chat
backend/src/schemas/memory.ts
ts
4,800
af391944706a8e16e3b2f499e808daf10935a99a3e007d008a1ead17fac41847
/** * Zod schemas for memory extraction - graceful validation with fallbacks. */ import { z } from 'zod'; /** * Entity schema for memory extraction */ export const memoryEntitiesSchema = z.object({ people: z.array(z.string()).default([]), topics: z.array(z.string()).default([]), tasks: z.array(z.string()).d...
eren23/non_linear_ai_chat
backend/src/schemas/generate.ts
ts
2,976
b850d2dbf24a24dc9d2097ebbc96c099b6afc59789e459916da1d74d0def1802
/** * Zod schemas for generation routes. */ import { z } from 'zod'; /** * Known tool names — must match the registered tools in services/tools/index.ts. * Used to whitelist enabledTools in the generate request and prevent log injection. */ export const KNOWN_TOOL_NAMES = [ 'web_search', 'rag_search', 'mem...
eren23/non_linear_ai_chat
backend/src/schemas/documentChat.ts
ts
2,028
e4e7914877227a552bad79dea41fd592795ab532f4bde75748d2e11a9beb1513
/** * Zod schemas for document chat routes. */ import { z } from 'zod'; const objectIdRegex = /^[0-9a-fA-F]{24}$/; export const sessionIdParamsSchema = z.object({ sessionId: z.string().regex(objectIdRegex, 'Invalid session ID'), }); export const documentIdParamsSchema = z.object({ documentId: z.string().regex...
eren23/non_linear_ai_chat
backend/src/schemas/tasks.ts
ts
525
735dd17321ec61994dab577822e3822400e33f122435fb0b93c09d82248b005b
/** * Zod schemas for task routes. */ import { z } from 'zod'; export const getTasksQuerySchema = z.object({ status: z.union([z.string(), z.array(z.string())]).optional(), limit: z.coerce.number().min(1).max(200).optional(), includeCompleted: z.enum(['true', 'false']).optional(), }); export const taskIdParam...
eren23/non_linear_ai_chat
backend/src/schemas/userProfile.ts
ts
698
227ae8adc6bdb76c7b69ba47d47cbdd949519f8380628a4d6da60821b01d423b
/** * Zod schemas for user profile routes. */ import { z } from 'zod'; /** * Search query schema for semantic search across personal knowledge. */ export const searchQuerySchema = z.object({ q: z.string() .min(1, 'Query is required') .max(1000, 'Query too long (max 1000 characters)'), limit: z.coerce....
eren23/non_linear_ai_chat
backend/src/schemas/__tests__/localAuth.test.ts
ts
6,093
33e5644d351cca6cfb8cc0e957f9f3b9153d90dcc4f6b558c2f4ad9cc0971784
import { describe, it, expect } from 'vitest'; import { registerSchema, loginSchema, resetPasswordSchema, forgotPasswordSchema, resendVerificationSchema, } from '../localAuth'; describe('registerSchema', () => { it('should accept a valid registration payload', () => { const result = registerSchema.pars...