GGitHubTesting framework (#2344)
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
Testing framework (#2344) * chore(tests): init test dir * chore(tests): add neverthrow * chore(tests): add chalk * feat(logger): add logger for tests * chore(tests): add zod * chore(tests): add types for node * feat(error): add error handling utils * chore(tests): add fs-extra * chore(tests): add execa * feat(utils): add utility functions for async operations - add `isStringifiable` function to check if data can be converted to string - add `delay` function that returns a promise wrapped in ResultAsync - add `safeExeca` function to execute shell commands safely - export all utility functions for use throughout the codebase These utilities improve error handling and provide type-safe async operations. * chore(tests): add eslint * chore(tests): bump vitest * chore(tests): add dotenv * build: add vitest config * chore(tests): add ianvs prettier sort plugin * build: add prettier config * chore(tests): add ora spinner * chore(tests): add typesense-js * chore(tests): add t3 env core * feat(platform): add getPlatform function for OS detection - add `getPlatform()` function that returns platform flag based on architecture - implement logic to detect x64, arm and arm64 architectures - default to `linux/amd64` for unrecognized architectures * feat(typesense): add process manager for test environment - implement `TypesenseProcessController` to manage individual process instances - create `TypesenseProcessManager` class to coordinate multiple processes - add support for multi-node typesense cluster configuration - implement methods for process lifecycle (start, stop, restart) - add health check and snapshot capabilities - handle network detection for proper node communication - implement safe cleanup on process exit This enables running typesense instances in test environments with proper lifecycle management. * feat(typesense): add global manager with environment configuration - create singleton `globalTypesenseManager` instance - implement `startTypesenseServer` function to initialize nodes - add `restartTypesenseServerFresh` for clean restarts - create `fetchNode` utility for API interactions - integrate environment configuration using t3-oss/env-core - set up environment variables for binary paths and directories This provides a centralized interface for managing typesense instances across tests. * test(env): add validation tests for environment configuration - add tests for environment variable validation using t3-oss/env-core - verify validation fails when required variables are missing - confirm validation passes with all required variables - test optional variable handling with TYPESENSE_SNAPSHOT_PATH - ensure proper error throwing behavior for various configurations This ensures robust environment validation for typesense test setup. * test(typesense): add integration tests for server lifecycle - implement test for server startup with multi-node verification - add test for restarting server with clean state - verify node configurations match expected port and directory settings - test collection creation and persistence between operations - validate collection data is cleared after restart * refactor(typesense): extract node directory mapping to separate method - extract `mapNodesToDirectories` method to improve code maintainability - reuse this method in `createDataDirectories` function - simplify directory mapping logic by using the new helper method * feat(typesense): add option to skip data directory cleanup - add `SetupNodesOptions` interface with `skipCleanup` option - modify `setupNodes` method to accept optional parameters - implement conditional logic to skip data directory cleanup when specified - reuse `mapNodesToDirectories` helper method for directory mapping * feat(utils): add URL construction utility - implement typed `UrlString` pattern with protocol, domain, port and path - add `constructUrl` helper function for building URLs with endpoints and params - create type definitions for URL components (Protocol, Domain, Port, Path) - export the new utility alongside existing functions * feat(typesense): add server restart with data preservation - implement `restartTypesenseServer` function that preserves data directories - update `startTypesenseServer` to accept optional configuration parameters - import `SetupNodesOptions` type to enable skipCleanup functionality - add 10-second delay with progress indicator during cleanup proces * feat(api): enhance fetchNode with URL construction and error handling - integrate `constructUrl` utility for building API request URLs - add support for query parameters in API requests - improve error handling with detailed HTTP error messages - add type safety with generic query parameters support - properly format endpoint paths with consistent leading slashes * test: add test case for restart with data preservation - add test for `restartTypesenseServer()` that verifies data persistence - import the non-fresh restart function from global manager - verify collection persistence across server restarts - check node configuration consistency before and after restart * feat: add configurable wait time to restart functions - add `waitForSeconds` parameter with default of 10 to both restart functions - replace hardcoded 10 second delay with configurable parameter - update log message to display dynamic wait time - ensure backward compatibility by making parameter optional * docs: add jsdom for global functions * feat(env): add optional IP address configuration parameter - add `TYPESENSE_IP_ADDRESS` as optional environment variable - update typesense manager initialization with IP address parameter - pass IP configuration to process manager constructor * perf: remove unnecessary delay in server startup sequence - remove 8-second artificial delay from startup process - keep health check verification as safety mechanism - improve test execution speed by eliminating wait time * fix: implement proper async process termination - replace synchronous `dispose()` with async promise-based implementation - add proper exit event handling with cleanup for both processes - prevent resource leaks by adding timeout clearing on exit - add detailed logging for process termination - fix type imports to improve code organization * perf: remove default wait time from restart procedure - change default `waitForSeconds` from 10 to 0 in `restartTypesenseServer` - eliminate unnecessary delay between process termination and restart - maintain parameter for cases where wait time is needed * perf: remove all wait times from restart operations - remove `waitForSeconds` parameter and functionality from both restart functions - eliminate delay import as it's no longer needed - remove 10-second wait in process manager restart method - simplify restart logic for more efficient test execution * perf: shorten delay before querying the master node * fix(client): adjust client retry parameters for typesense process - reduce `retryIntervalSeconds` from 10 to 3 seconds - increase `numRetries` from 6 to 20 attempts * chore: add openai and faker to deps * feat: implement openai proxy interceptor for testing - add new `openai.ts` module with proxy server functionality - implement mock response handling for openai api endpoints - support dynamic configuration of embedding dimensions - add self-signed certificate generation for https connections * feat: add environment variable for embedding dimensions - add `TYPESENSE_NUM_DIM` configuration with default value of 256 - integrate with environment validation schema in typesense manager * fix(env): enable empty string to undefined conversion in env parser - add `emptyStringAsUndefined: true` option to environment config - ensures empty environment variables are treated as undefined values * fix(manager): use default snapshot path when not specified - add fallback logic for snapshot path configuration - set default path as subdirectory within working directory - improve initialization with explicit variable assignment * refactor(manager): share spinner instance between components - extract `ora()` instance to separate variable - reuse spinner across manager initialization - prepare for sharing spinner with other components * feat: initialize and export openai proxy instance - create openai proxy with shared spinner instance - configure proxy with environment settings - export proxy for test suite consumption * feat(manager): add function to properly shutdown typesense server - implement `closeDownTypesenseServer` function - dispose all process instances and clean up resources - export function for test suite teardown procedures * feat(fetch): implement retry mechanism for node fetch operations - add automatic retry logic to `fetchNode` function - support configurable retry count and delay intervals - improve error handling with detailed failure messages - reorganize function parameters with dedicated interface * test: add cleanup handler for test server resources - implement `afterAll` hook to shutdown typesense server - use new `closeDownTypesenseServer` function for proper cleanup - prevent resource leaks between test runs * build(tests): disable parallel test execution - set `fileParallelism` to false to run tests sequentially - configure sequence options to maintain test order - prevent test interference when sharing typesense resources * test: add conversation model persistence across node restarts - implement test for conversation model availability after rotation - verify model configuration is preserved when nodes restart - initialize and cleanup openai proxy for conversation testing - create necessary collections and conversation store * test: verify openai embedding dimensions configuration - add test for embedding vector dimensions persistence - validate dimensions match environment configuration - confirm settings survive server restarts - integrate mock openai proxy for embedding tests * test: test snapshot functionality - add test to verify snapshot creation process - confirm snapshot files are correctly stored in configured location - validate document indexing and collection creation before snapshot - check for snapshot directory and file existence * refactor(benchmark): improve process management and add FS utilities - refactor `TypesenseProcessManager` to use proper error handling with `Result` types - replace direct fs operations with safer utilities from new `fs.ts` module - improve process disposal with proper async handling and event listeners - add network interface detection for better peering address resolution - modify k6 benchmark collection creation to use client directly - enhance logging with m * refactor(benchmark): rename benchmark function to `perform` * refactor(benchmark): extract file system utilities to dedicated module - move `getPlatform` function from `services/fs.ts` to new `utils/fs.ts` file - add new file system utility functions for safer FS operations - implement `exists`, `safeRm`, `safeMakeOrEmptyDir`, and `safeEmptyDir` with proper error handling - use `ResultAsync` from neverthrow for consistent error handling pattern - provide strongly typed interfaces for all FS operations * refactor(benchmark): reorganize utility functions for better organization - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` module - add `constructUrl` function with strongly typed parameters in `utils/base.ts` - implement safe file system operations with proper error h * refactor(benchmark): reorganize utilities and improve service architecture - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - update imports across files to reference new utility locations * feat(benchmark): reorganize utilities and add centralized service management - create new `global.ts` module for centralized Typesense server and OpenAI proxy management - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` utility module - add type-safe `constructUrl` function and network fetch utilities - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - implement environment variable management with t3-oss/env-core - add server lifecycle management functions (start, restart, close) - enhance error handling with consistent `ResultAsync` pattern throughout - improve TypesenseProcessManager with better health checks and network detection - update imports across all affected files * chore(benchmark): add t3-oss/env * refactor: remove integration tests from commands - remove `tests.ts` file containing integration test command (712 lines) - remove test command registration from `index.ts` - remove test command import from `index.ts` * chore(benchmark): add dotenv * refactor: relocate and refactor test files - move test files from `tests/tests/` to `benchmark/test/` - move vitest config from `tests/` to `benchmark/` - update import paths to match new directory structure - fix optional chaining in openai-embedding test - remove `tests.ts` command file (previous commit) * ci: change testing command to native pnpm script * build(vitest): configure setup function to ensure working-dir exists * ci: fix env vars for tests * ci: remove unecessary build step on tests * chore: bump typesense-js * feat(fetch): add typesense endpoint type definitions - Add `Endpoints` interface mapping api paths to http methods - Import typesense type definitions for collections, documents, and operations - Add utility types for path transformation and endpoint response inference - Improve type safety for api interactions in benchmark module * refactor(benchmark): implement type-safe api client with endpoint inference - Update `FetchNodeParams` interface to use typed endpoint definitions - Modify `fetchNode` function to infer request/response types from endpoint schema - Remove explicit type parameters from `fetchNode` calls in tests - Add conditional type mapping for body and query parameters based on endpoint - Improve type safety by eliminating manual type annotations * feat(fetch): add manual document generic passing by prefixed `~type` key - Avoid having to define all 3 generics by adding a prefixed `~type` key in the `FetchNode` parameters schema, so Typescript will infer the document type based on that parameter * fix(tests): remove unused generic type params in tests | 1 年前 | |
Testing framework (#2344) * chore(tests): init test dir * chore(tests): add neverthrow * chore(tests): add chalk * feat(logger): add logger for tests * chore(tests): add zod * chore(tests): add types for node * feat(error): add error handling utils * chore(tests): add fs-extra * chore(tests): add execa * feat(utils): add utility functions for async operations - add `isStringifiable` function to check if data can be converted to string - add `delay` function that returns a promise wrapped in ResultAsync - add `safeExeca` function to execute shell commands safely - export all utility functions for use throughout the codebase These utilities improve error handling and provide type-safe async operations. * chore(tests): add eslint * chore(tests): bump vitest * chore(tests): add dotenv * build: add vitest config * chore(tests): add ianvs prettier sort plugin * build: add prettier config * chore(tests): add ora spinner * chore(tests): add typesense-js * chore(tests): add t3 env core * feat(platform): add getPlatform function for OS detection - add `getPlatform()` function that returns platform flag based on architecture - implement logic to detect x64, arm and arm64 architectures - default to `linux/amd64` for unrecognized architectures * feat(typesense): add process manager for test environment - implement `TypesenseProcessController` to manage individual process instances - create `TypesenseProcessManager` class to coordinate multiple processes - add support for multi-node typesense cluster configuration - implement methods for process lifecycle (start, stop, restart) - add health check and snapshot capabilities - handle network detection for proper node communication - implement safe cleanup on process exit This enables running typesense instances in test environments with proper lifecycle management. * feat(typesense): add global manager with environment configuration - create singleton `globalTypesenseManager` instance - implement `startTypesenseServer` function to initialize nodes - add `restartTypesenseServerFresh` for clean restarts - create `fetchNode` utility for API interactions - integrate environment configuration using t3-oss/env-core - set up environment variables for binary paths and directories This provides a centralized interface for managing typesense instances across tests. * test(env): add validation tests for environment configuration - add tests for environment variable validation using t3-oss/env-core - verify validation fails when required variables are missing - confirm validation passes with all required variables - test optional variable handling with TYPESENSE_SNAPSHOT_PATH - ensure proper error throwing behavior for various configurations This ensures robust environment validation for typesense test setup. * test(typesense): add integration tests for server lifecycle - implement test for server startup with multi-node verification - add test for restarting server with clean state - verify node configurations match expected port and directory settings - test collection creation and persistence between operations - validate collection data is cleared after restart * refactor(typesense): extract node directory mapping to separate method - extract `mapNodesToDirectories` method to improve code maintainability - reuse this method in `createDataDirectories` function - simplify directory mapping logic by using the new helper method * feat(typesense): add option to skip data directory cleanup - add `SetupNodesOptions` interface with `skipCleanup` option - modify `setupNodes` method to accept optional parameters - implement conditional logic to skip data directory cleanup when specified - reuse `mapNodesToDirectories` helper method for directory mapping * feat(utils): add URL construction utility - implement typed `UrlString` pattern with protocol, domain, port and path - add `constructUrl` helper function for building URLs with endpoints and params - create type definitions for URL components (Protocol, Domain, Port, Path) - export the new utility alongside existing functions * feat(typesense): add server restart with data preservation - implement `restartTypesenseServer` function that preserves data directories - update `startTypesenseServer` to accept optional configuration parameters - import `SetupNodesOptions` type to enable skipCleanup functionality - add 10-second delay with progress indicator during cleanup proces * feat(api): enhance fetchNode with URL construction and error handling - integrate `constructUrl` utility for building API request URLs - add support for query parameters in API requests - improve error handling with detailed HTTP error messages - add type safety with generic query parameters support - properly format endpoint paths with consistent leading slashes * test: add test case for restart with data preservation - add test for `restartTypesenseServer()` that verifies data persistence - import the non-fresh restart function from global manager - verify collection persistence across server restarts - check node configuration consistency before and after restart * feat: add configurable wait time to restart functions - add `waitForSeconds` parameter with default of 10 to both restart functions - replace hardcoded 10 second delay with configurable parameter - update log message to display dynamic wait time - ensure backward compatibility by making parameter optional * docs: add jsdom for global functions * feat(env): add optional IP address configuration parameter - add `TYPESENSE_IP_ADDRESS` as optional environment variable - update typesense manager initialization with IP address parameter - pass IP configuration to process manager constructor * perf: remove unnecessary delay in server startup sequence - remove 8-second artificial delay from startup process - keep health check verification as safety mechanism - improve test execution speed by eliminating wait time * fix: implement proper async process termination - replace synchronous `dispose()` with async promise-based implementation - add proper exit event handling with cleanup for both processes - prevent resource leaks by adding timeout clearing on exit - add detailed logging for process termination - fix type imports to improve code organization * perf: remove default wait time from restart procedure - change default `waitForSeconds` from 10 to 0 in `restartTypesenseServer` - eliminate unnecessary delay between process termination and restart - maintain parameter for cases where wait time is needed * perf: remove all wait times from restart operations - remove `waitForSeconds` parameter and functionality from both restart functions - eliminate delay import as it's no longer needed - remove 10-second wait in process manager restart method - simplify restart logic for more efficient test execution * perf: shorten delay before querying the master node * fix(client): adjust client retry parameters for typesense process - reduce `retryIntervalSeconds` from 10 to 3 seconds - increase `numRetries` from 6 to 20 attempts * chore: add openai and faker to deps * feat: implement openai proxy interceptor for testing - add new `openai.ts` module with proxy server functionality - implement mock response handling for openai api endpoints - support dynamic configuration of embedding dimensions - add self-signed certificate generation for https connections * feat: add environment variable for embedding dimensions - add `TYPESENSE_NUM_DIM` configuration with default value of 256 - integrate with environment validation schema in typesense manager * fix(env): enable empty string to undefined conversion in env parser - add `emptyStringAsUndefined: true` option to environment config - ensures empty environment variables are treated as undefined values * fix(manager): use default snapshot path when not specified - add fallback logic for snapshot path configuration - set default path as subdirectory within working directory - improve initialization with explicit variable assignment * refactor(manager): share spinner instance between components - extract `ora()` instance to separate variable - reuse spinner across manager initialization - prepare for sharing spinner with other components * feat: initialize and export openai proxy instance - create openai proxy with shared spinner instance - configure proxy with environment settings - export proxy for test suite consumption * feat(manager): add function to properly shutdown typesense server - implement `closeDownTypesenseServer` function - dispose all process instances and clean up resources - export function for test suite teardown procedures * feat(fetch): implement retry mechanism for node fetch operations - add automatic retry logic to `fetchNode` function - support configurable retry count and delay intervals - improve error handling with detailed failure messages - reorganize function parameters with dedicated interface * test: add cleanup handler for test server resources - implement `afterAll` hook to shutdown typesense server - use new `closeDownTypesenseServer` function for proper cleanup - prevent resource leaks between test runs * build(tests): disable parallel test execution - set `fileParallelism` to false to run tests sequentially - configure sequence options to maintain test order - prevent test interference when sharing typesense resources * test: add conversation model persistence across node restarts - implement test for conversation model availability after rotation - verify model configuration is preserved when nodes restart - initialize and cleanup openai proxy for conversation testing - create necessary collections and conversation store * test: verify openai embedding dimensions configuration - add test for embedding vector dimensions persistence - validate dimensions match environment configuration - confirm settings survive server restarts - integrate mock openai proxy for embedding tests * test: test snapshot functionality - add test to verify snapshot creation process - confirm snapshot files are correctly stored in configured location - validate document indexing and collection creation before snapshot - check for snapshot directory and file existence * refactor(benchmark): improve process management and add FS utilities - refactor `TypesenseProcessManager` to use proper error handling with `Result` types - replace direct fs operations with safer utilities from new `fs.ts` module - improve process disposal with proper async handling and event listeners - add network interface detection for better peering address resolution - modify k6 benchmark collection creation to use client directly - enhance logging with m * refactor(benchmark): rename benchmark function to `perform` * refactor(benchmark): extract file system utilities to dedicated module - move `getPlatform` function from `services/fs.ts` to new `utils/fs.ts` file - add new file system utility functions for safer FS operations - implement `exists`, `safeRm`, `safeMakeOrEmptyDir`, and `safeEmptyDir` with proper error handling - use `ResultAsync` from neverthrow for consistent error handling pattern - provide strongly typed interfaces for all FS operations * refactor(benchmark): reorganize utility functions for better organization - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` module - add `constructUrl` function with strongly typed parameters in `utils/base.ts` - implement safe file system operations with proper error h * refactor(benchmark): reorganize utilities and improve service architecture - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - update imports across files to reference new utility locations * feat(benchmark): reorganize utilities and add centralized service management - create new `global.ts` module for centralized Typesense server and OpenAI proxy management - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` utility module - add type-safe `constructUrl` function and network fetch utilities - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - implement environment variable management with t3-oss/env-core - add server lifecycle management functions (start, restart, close) - enhance error handling with consistent `ResultAsync` pattern throughout - improve TypesenseProcessManager with better health checks and network detection - update imports across all affected files * chore(benchmark): add t3-oss/env * refactor: remove integration tests from commands - remove `tests.ts` file containing integration test command (712 lines) - remove test command registration from `index.ts` - remove test command import from `index.ts` * chore(benchmark): add dotenv * refactor: relocate and refactor test files - move test files from `tests/tests/` to `benchmark/test/` - move vitest config from `tests/` to `benchmark/` - update import paths to match new directory structure - fix optional chaining in openai-embedding test - remove `tests.ts` command file (previous commit) * ci: change testing command to native pnpm script * build(vitest): configure setup function to ensure working-dir exists * ci: fix env vars for tests * ci: remove unecessary build step on tests * chore: bump typesense-js * feat(fetch): add typesense endpoint type definitions - Add `Endpoints` interface mapping api paths to http methods - Import typesense type definitions for collections, documents, and operations - Add utility types for path transformation and endpoint response inference - Improve type safety for api interactions in benchmark module * refactor(benchmark): implement type-safe api client with endpoint inference - Update `FetchNodeParams` interface to use typed endpoint definitions - Modify `fetchNode` function to infer request/response types from endpoint schema - Remove explicit type parameters from `fetchNode` calls in tests - Add conditional type mapping for body and query parameters based on endpoint - Improve type safety by eliminating manual type annotations * feat(fetch): add manual document generic passing by prefixed `~type` key - Avoid having to define all 3 generics by adding a prefixed `~type` key in the `FetchNode` parameters schema, so Typescript will infer the document type based on that parameter * fix(tests): remove unused generic type params in tests | 1 年前 | |
Testing framework (#2344) * chore(tests): init test dir * chore(tests): add neverthrow * chore(tests): add chalk * feat(logger): add logger for tests * chore(tests): add zod * chore(tests): add types for node * feat(error): add error handling utils * chore(tests): add fs-extra * chore(tests): add execa * feat(utils): add utility functions for async operations - add `isStringifiable` function to check if data can be converted to string - add `delay` function that returns a promise wrapped in ResultAsync - add `safeExeca` function to execute shell commands safely - export all utility functions for use throughout the codebase These utilities improve error handling and provide type-safe async operations. * chore(tests): add eslint * chore(tests): bump vitest * chore(tests): add dotenv * build: add vitest config * chore(tests): add ianvs prettier sort plugin * build: add prettier config * chore(tests): add ora spinner * chore(tests): add typesense-js * chore(tests): add t3 env core * feat(platform): add getPlatform function for OS detection - add `getPlatform()` function that returns platform flag based on architecture - implement logic to detect x64, arm and arm64 architectures - default to `linux/amd64` for unrecognized architectures * feat(typesense): add process manager for test environment - implement `TypesenseProcessController` to manage individual process instances - create `TypesenseProcessManager` class to coordinate multiple processes - add support for multi-node typesense cluster configuration - implement methods for process lifecycle (start, stop, restart) - add health check and snapshot capabilities - handle network detection for proper node communication - implement safe cleanup on process exit This enables running typesense instances in test environments with proper lifecycle management. * feat(typesense): add global manager with environment configuration - create singleton `globalTypesenseManager` instance - implement `startTypesenseServer` function to initialize nodes - add `restartTypesenseServerFresh` for clean restarts - create `fetchNode` utility for API interactions - integrate environment configuration using t3-oss/env-core - set up environment variables for binary paths and directories This provides a centralized interface for managing typesense instances across tests. * test(env): add validation tests for environment configuration - add tests for environment variable validation using t3-oss/env-core - verify validation fails when required variables are missing - confirm validation passes with all required variables - test optional variable handling with TYPESENSE_SNAPSHOT_PATH - ensure proper error throwing behavior for various configurations This ensures robust environment validation for typesense test setup. * test(typesense): add integration tests for server lifecycle - implement test for server startup with multi-node verification - add test for restarting server with clean state - verify node configurations match expected port and directory settings - test collection creation and persistence between operations - validate collection data is cleared after restart * refactor(typesense): extract node directory mapping to separate method - extract `mapNodesToDirectories` method to improve code maintainability - reuse this method in `createDataDirectories` function - simplify directory mapping logic by using the new helper method * feat(typesense): add option to skip data directory cleanup - add `SetupNodesOptions` interface with `skipCleanup` option - modify `setupNodes` method to accept optional parameters - implement conditional logic to skip data directory cleanup when specified - reuse `mapNodesToDirectories` helper method for directory mapping * feat(utils): add URL construction utility - implement typed `UrlString` pattern with protocol, domain, port and path - add `constructUrl` helper function for building URLs with endpoints and params - create type definitions for URL components (Protocol, Domain, Port, Path) - export the new utility alongside existing functions * feat(typesense): add server restart with data preservation - implement `restartTypesenseServer` function that preserves data directories - update `startTypesenseServer` to accept optional configuration parameters - import `SetupNodesOptions` type to enable skipCleanup functionality - add 10-second delay with progress indicator during cleanup proces * feat(api): enhance fetchNode with URL construction and error handling - integrate `constructUrl` utility for building API request URLs - add support for query parameters in API requests - improve error handling with detailed HTTP error messages - add type safety with generic query parameters support - properly format endpoint paths with consistent leading slashes * test: add test case for restart with data preservation - add test for `restartTypesenseServer()` that verifies data persistence - import the non-fresh restart function from global manager - verify collection persistence across server restarts - check node configuration consistency before and after restart * feat: add configurable wait time to restart functions - add `waitForSeconds` parameter with default of 10 to both restart functions - replace hardcoded 10 second delay with configurable parameter - update log message to display dynamic wait time - ensure backward compatibility by making parameter optional * docs: add jsdom for global functions * feat(env): add optional IP address configuration parameter - add `TYPESENSE_IP_ADDRESS` as optional environment variable - update typesense manager initialization with IP address parameter - pass IP configuration to process manager constructor * perf: remove unnecessary delay in server startup sequence - remove 8-second artificial delay from startup process - keep health check verification as safety mechanism - improve test execution speed by eliminating wait time * fix: implement proper async process termination - replace synchronous `dispose()` with async promise-based implementation - add proper exit event handling with cleanup for both processes - prevent resource leaks by adding timeout clearing on exit - add detailed logging for process termination - fix type imports to improve code organization * perf: remove default wait time from restart procedure - change default `waitForSeconds` from 10 to 0 in `restartTypesenseServer` - eliminate unnecessary delay between process termination and restart - maintain parameter for cases where wait time is needed * perf: remove all wait times from restart operations - remove `waitForSeconds` parameter and functionality from both restart functions - eliminate delay import as it's no longer needed - remove 10-second wait in process manager restart method - simplify restart logic for more efficient test execution * perf: shorten delay before querying the master node * fix(client): adjust client retry parameters for typesense process - reduce `retryIntervalSeconds` from 10 to 3 seconds - increase `numRetries` from 6 to 20 attempts * chore: add openai and faker to deps * feat: implement openai proxy interceptor for testing - add new `openai.ts` module with proxy server functionality - implement mock response handling for openai api endpoints - support dynamic configuration of embedding dimensions - add self-signed certificate generation for https connections * feat: add environment variable for embedding dimensions - add `TYPESENSE_NUM_DIM` configuration with default value of 256 - integrate with environment validation schema in typesense manager * fix(env): enable empty string to undefined conversion in env parser - add `emptyStringAsUndefined: true` option to environment config - ensures empty environment variables are treated as undefined values * fix(manager): use default snapshot path when not specified - add fallback logic for snapshot path configuration - set default path as subdirectory within working directory - improve initialization with explicit variable assignment * refactor(manager): share spinner instance between components - extract `ora()` instance to separate variable - reuse spinner across manager initialization - prepare for sharing spinner with other components * feat: initialize and export openai proxy instance - create openai proxy with shared spinner instance - configure proxy with environment settings - export proxy for test suite consumption * feat(manager): add function to properly shutdown typesense server - implement `closeDownTypesenseServer` function - dispose all process instances and clean up resources - export function for test suite teardown procedures * feat(fetch): implement retry mechanism for node fetch operations - add automatic retry logic to `fetchNode` function - support configurable retry count and delay intervals - improve error handling with detailed failure messages - reorganize function parameters with dedicated interface * test: add cleanup handler for test server resources - implement `afterAll` hook to shutdown typesense server - use new `closeDownTypesenseServer` function for proper cleanup - prevent resource leaks between test runs * build(tests): disable parallel test execution - set `fileParallelism` to false to run tests sequentially - configure sequence options to maintain test order - prevent test interference when sharing typesense resources * test: add conversation model persistence across node restarts - implement test for conversation model availability after rotation - verify model configuration is preserved when nodes restart - initialize and cleanup openai proxy for conversation testing - create necessary collections and conversation store * test: verify openai embedding dimensions configuration - add test for embedding vector dimensions persistence - validate dimensions match environment configuration - confirm settings survive server restarts - integrate mock openai proxy for embedding tests * test: test snapshot functionality - add test to verify snapshot creation process - confirm snapshot files are correctly stored in configured location - validate document indexing and collection creation before snapshot - check for snapshot directory and file existence * refactor(benchmark): improve process management and add FS utilities - refactor `TypesenseProcessManager` to use proper error handling with `Result` types - replace direct fs operations with safer utilities from new `fs.ts` module - improve process disposal with proper async handling and event listeners - add network interface detection for better peering address resolution - modify k6 benchmark collection creation to use client directly - enhance logging with m * refactor(benchmark): rename benchmark function to `perform` * refactor(benchmark): extract file system utilities to dedicated module - move `getPlatform` function from `services/fs.ts` to new `utils/fs.ts` file - add new file system utility functions for safer FS operations - implement `exists`, `safeRm`, `safeMakeOrEmptyDir`, and `safeEmptyDir` with proper error handling - use `ResultAsync` from neverthrow for consistent error handling pattern - provide strongly typed interfaces for all FS operations * refactor(benchmark): reorganize utility functions for better organization - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` module - add `constructUrl` function with strongly typed parameters in `utils/base.ts` - implement safe file system operations with proper error h * refactor(benchmark): reorganize utilities and improve service architecture - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - update imports across files to reference new utility locations * feat(benchmark): reorganize utilities and add centralized service management - create new `global.ts` module for centralized Typesense server and OpenAI proxy management - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` utility module - add type-safe `constructUrl` function and network fetch utilities - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - implement environment variable management with t3-oss/env-core - add server lifecycle management functions (start, restart, close) - enhance error handling with consistent `ResultAsync` pattern throughout - improve TypesenseProcessManager with better health checks and network detection - update imports across all affected files * chore(benchmark): add t3-oss/env * refactor: remove integration tests from commands - remove `tests.ts` file containing integration test command (712 lines) - remove test command registration from `index.ts` - remove test command import from `index.ts` * chore(benchmark): add dotenv * refactor: relocate and refactor test files - move test files from `tests/tests/` to `benchmark/test/` - move vitest config from `tests/` to `benchmark/` - update import paths to match new directory structure - fix optional chaining in openai-embedding test - remove `tests.ts` command file (previous commit) * ci: change testing command to native pnpm script * build(vitest): configure setup function to ensure working-dir exists * ci: fix env vars for tests * ci: remove unecessary build step on tests * chore: bump typesense-js * feat(fetch): add typesense endpoint type definitions - Add `Endpoints` interface mapping api paths to http methods - Import typesense type definitions for collections, documents, and operations - Add utility types for path transformation and endpoint response inference - Improve type safety for api interactions in benchmark module * refactor(benchmark): implement type-safe api client with endpoint inference - Update `FetchNodeParams` interface to use typed endpoint definitions - Modify `fetchNode` function to infer request/response types from endpoint schema - Remove explicit type parameters from `fetchNode` calls in tests - Add conditional type mapping for body and query parameters based on endpoint - Improve type safety by eliminating manual type annotations * feat(fetch): add manual document generic passing by prefixed `~type` key - Avoid having to define all 3 generics by adding a prefixed `~type` key in the `FetchNode` parameters schema, so Typescript will infer the document type based on that parameter * fix(tests): remove unused generic type params in tests | 1 年前 | |
Testing framework (#2344) * chore(tests): init test dir * chore(tests): add neverthrow * chore(tests): add chalk * feat(logger): add logger for tests * chore(tests): add zod * chore(tests): add types for node * feat(error): add error handling utils * chore(tests): add fs-extra * chore(tests): add execa * feat(utils): add utility functions for async operations - add `isStringifiable` function to check if data can be converted to string - add `delay` function that returns a promise wrapped in ResultAsync - add `safeExeca` function to execute shell commands safely - export all utility functions for use throughout the codebase These utilities improve error handling and provide type-safe async operations. * chore(tests): add eslint * chore(tests): bump vitest * chore(tests): add dotenv * build: add vitest config * chore(tests): add ianvs prettier sort plugin * build: add prettier config * chore(tests): add ora spinner * chore(tests): add typesense-js * chore(tests): add t3 env core * feat(platform): add getPlatform function for OS detection - add `getPlatform()` function that returns platform flag based on architecture - implement logic to detect x64, arm and arm64 architectures - default to `linux/amd64` for unrecognized architectures * feat(typesense): add process manager for test environment - implement `TypesenseProcessController` to manage individual process instances - create `TypesenseProcessManager` class to coordinate multiple processes - add support for multi-node typesense cluster configuration - implement methods for process lifecycle (start, stop, restart) - add health check and snapshot capabilities - handle network detection for proper node communication - implement safe cleanup on process exit This enables running typesense instances in test environments with proper lifecycle management. * feat(typesense): add global manager with environment configuration - create singleton `globalTypesenseManager` instance - implement `startTypesenseServer` function to initialize nodes - add `restartTypesenseServerFresh` for clean restarts - create `fetchNode` utility for API interactions - integrate environment configuration using t3-oss/env-core - set up environment variables for binary paths and directories This provides a centralized interface for managing typesense instances across tests. * test(env): add validation tests for environment configuration - add tests for environment variable validation using t3-oss/env-core - verify validation fails when required variables are missing - confirm validation passes with all required variables - test optional variable handling with TYPESENSE_SNAPSHOT_PATH - ensure proper error throwing behavior for various configurations This ensures robust environment validation for typesense test setup. * test(typesense): add integration tests for server lifecycle - implement test for server startup with multi-node verification - add test for restarting server with clean state - verify node configurations match expected port and directory settings - test collection creation and persistence between operations - validate collection data is cleared after restart * refactor(typesense): extract node directory mapping to separate method - extract `mapNodesToDirectories` method to improve code maintainability - reuse this method in `createDataDirectories` function - simplify directory mapping logic by using the new helper method * feat(typesense): add option to skip data directory cleanup - add `SetupNodesOptions` interface with `skipCleanup` option - modify `setupNodes` method to accept optional parameters - implement conditional logic to skip data directory cleanup when specified - reuse `mapNodesToDirectories` helper method for directory mapping * feat(utils): add URL construction utility - implement typed `UrlString` pattern with protocol, domain, port and path - add `constructUrl` helper function for building URLs with endpoints and params - create type definitions for URL components (Protocol, Domain, Port, Path) - export the new utility alongside existing functions * feat(typesense): add server restart with data preservation - implement `restartTypesenseServer` function that preserves data directories - update `startTypesenseServer` to accept optional configuration parameters - import `SetupNodesOptions` type to enable skipCleanup functionality - add 10-second delay with progress indicator during cleanup proces * feat(api): enhance fetchNode with URL construction and error handling - integrate `constructUrl` utility for building API request URLs - add support for query parameters in API requests - improve error handling with detailed HTTP error messages - add type safety with generic query parameters support - properly format endpoint paths with consistent leading slashes * test: add test case for restart with data preservation - add test for `restartTypesenseServer()` that verifies data persistence - import the non-fresh restart function from global manager - verify collection persistence across server restarts - check node configuration consistency before and after restart * feat: add configurable wait time to restart functions - add `waitForSeconds` parameter with default of 10 to both restart functions - replace hardcoded 10 second delay with configurable parameter - update log message to display dynamic wait time - ensure backward compatibility by making parameter optional * docs: add jsdom for global functions * feat(env): add optional IP address configuration parameter - add `TYPESENSE_IP_ADDRESS` as optional environment variable - update typesense manager initialization with IP address parameter - pass IP configuration to process manager constructor * perf: remove unnecessary delay in server startup sequence - remove 8-second artificial delay from startup process - keep health check verification as safety mechanism - improve test execution speed by eliminating wait time * fix: implement proper async process termination - replace synchronous `dispose()` with async promise-based implementation - add proper exit event handling with cleanup for both processes - prevent resource leaks by adding timeout clearing on exit - add detailed logging for process termination - fix type imports to improve code organization * perf: remove default wait time from restart procedure - change default `waitForSeconds` from 10 to 0 in `restartTypesenseServer` - eliminate unnecessary delay between process termination and restart - maintain parameter for cases where wait time is needed * perf: remove all wait times from restart operations - remove `waitForSeconds` parameter and functionality from both restart functions - eliminate delay import as it's no longer needed - remove 10-second wait in process manager restart method - simplify restart logic for more efficient test execution * perf: shorten delay before querying the master node * fix(client): adjust client retry parameters for typesense process - reduce `retryIntervalSeconds` from 10 to 3 seconds - increase `numRetries` from 6 to 20 attempts * chore: add openai and faker to deps * feat: implement openai proxy interceptor for testing - add new `openai.ts` module with proxy server functionality - implement mock response handling for openai api endpoints - support dynamic configuration of embedding dimensions - add self-signed certificate generation for https connections * feat: add environment variable for embedding dimensions - add `TYPESENSE_NUM_DIM` configuration with default value of 256 - integrate with environment validation schema in typesense manager * fix(env): enable empty string to undefined conversion in env parser - add `emptyStringAsUndefined: true` option to environment config - ensures empty environment variables are treated as undefined values * fix(manager): use default snapshot path when not specified - add fallback logic for snapshot path configuration - set default path as subdirectory within working directory - improve initialization with explicit variable assignment * refactor(manager): share spinner instance between components - extract `ora()` instance to separate variable - reuse spinner across manager initialization - prepare for sharing spinner with other components * feat: initialize and export openai proxy instance - create openai proxy with shared spinner instance - configure proxy with environment settings - export proxy for test suite consumption * feat(manager): add function to properly shutdown typesense server - implement `closeDownTypesenseServer` function - dispose all process instances and clean up resources - export function for test suite teardown procedures * feat(fetch): implement retry mechanism for node fetch operations - add automatic retry logic to `fetchNode` function - support configurable retry count and delay intervals - improve error handling with detailed failure messages - reorganize function parameters with dedicated interface * test: add cleanup handler for test server resources - implement `afterAll` hook to shutdown typesense server - use new `closeDownTypesenseServer` function for proper cleanup - prevent resource leaks between test runs * build(tests): disable parallel test execution - set `fileParallelism` to false to run tests sequentially - configure sequence options to maintain test order - prevent test interference when sharing typesense resources * test: add conversation model persistence across node restarts - implement test for conversation model availability after rotation - verify model configuration is preserved when nodes restart - initialize and cleanup openai proxy for conversation testing - create necessary collections and conversation store * test: verify openai embedding dimensions configuration - add test for embedding vector dimensions persistence - validate dimensions match environment configuration - confirm settings survive server restarts - integrate mock openai proxy for embedding tests * test: test snapshot functionality - add test to verify snapshot creation process - confirm snapshot files are correctly stored in configured location - validate document indexing and collection creation before snapshot - check for snapshot directory and file existence * refactor(benchmark): improve process management and add FS utilities - refactor `TypesenseProcessManager` to use proper error handling with `Result` types - replace direct fs operations with safer utilities from new `fs.ts` module - improve process disposal with proper async handling and event listeners - add network interface detection for better peering address resolution - modify k6 benchmark collection creation to use client directly - enhance logging with m * refactor(benchmark): rename benchmark function to `perform` * refactor(benchmark): extract file system utilities to dedicated module - move `getPlatform` function from `services/fs.ts` to new `utils/fs.ts` file - add new file system utility functions for safer FS operations - implement `exists`, `safeRm`, `safeMakeOrEmptyDir`, and `safeEmptyDir` with proper error handling - use `ResultAsync` from neverthrow for consistent error handling pattern - provide strongly typed interfaces for all FS operations * refactor(benchmark): reorganize utility functions for better organization - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` module - add `constructUrl` function with strongly typed parameters in `utils/base.ts` - implement safe file system operations with proper error h * refactor(benchmark): reorganize utilities and improve service architecture - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - update imports across files to reference new utility locations * feat(benchmark): reorganize utilities and add centralized service management - create new `global.ts` module for centralized Typesense server and OpenAI proxy management - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` utility module - add type-safe `constructUrl` function and network fetch utilities - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - implement environment variable management with t3-oss/env-core - add server lifecycle management functions (start, restart, close) - enhance error handling with consistent `ResultAsync` pattern throughout - improve TypesenseProcessManager with better health checks and network detection - update imports across all affected files * chore(benchmark): add t3-oss/env * refactor: remove integration tests from commands - remove `tests.ts` file containing integration test command (712 lines) - remove test command registration from `index.ts` - remove test command import from `index.ts` * chore(benchmark): add dotenv * refactor: relocate and refactor test files - move test files from `tests/tests/` to `benchmark/test/` - move vitest config from `tests/` to `benchmark/` - update import paths to match new directory structure - fix optional chaining in openai-embedding test - remove `tests.ts` command file (previous commit) * ci: change testing command to native pnpm script * build(vitest): configure setup function to ensure working-dir exists * ci: fix env vars for tests * ci: remove unecessary build step on tests * chore: bump typesense-js * feat(fetch): add typesense endpoint type definitions - Add `Endpoints` interface mapping api paths to http methods - Import typesense type definitions for collections, documents, and operations - Add utility types for path transformation and endpoint response inference - Improve type safety for api interactions in benchmark module * refactor(benchmark): implement type-safe api client with endpoint inference - Update `FetchNodeParams` interface to use typed endpoint definitions - Modify `fetchNode` function to infer request/response types from endpoint schema - Remove explicit type parameters from `fetchNode` calls in tests - Add conditional type mapping for body and query parameters based on endpoint - Improve type safety by eliminating manual type annotations * feat(fetch): add manual document generic passing by prefixed `~type` key - Avoid having to define all 3 generics by adding a prefixed `~type` key in the `FetchNode` parameters schema, so Typescript will infer the document type based on that parameter * fix(tests): remove unused generic type params in tests | 1 年前 | |
Testing framework (#2344) * chore(tests): init test dir * chore(tests): add neverthrow * chore(tests): add chalk * feat(logger): add logger for tests * chore(tests): add zod * chore(tests): add types for node * feat(error): add error handling utils * chore(tests): add fs-extra * chore(tests): add execa * feat(utils): add utility functions for async operations - add `isStringifiable` function to check if data can be converted to string - add `delay` function that returns a promise wrapped in ResultAsync - add `safeExeca` function to execute shell commands safely - export all utility functions for use throughout the codebase These utilities improve error handling and provide type-safe async operations. * chore(tests): add eslint * chore(tests): bump vitest * chore(tests): add dotenv * build: add vitest config * chore(tests): add ianvs prettier sort plugin * build: add prettier config * chore(tests): add ora spinner * chore(tests): add typesense-js * chore(tests): add t3 env core * feat(platform): add getPlatform function for OS detection - add `getPlatform()` function that returns platform flag based on architecture - implement logic to detect x64, arm and arm64 architectures - default to `linux/amd64` for unrecognized architectures * feat(typesense): add process manager for test environment - implement `TypesenseProcessController` to manage individual process instances - create `TypesenseProcessManager` class to coordinate multiple processes - add support for multi-node typesense cluster configuration - implement methods for process lifecycle (start, stop, restart) - add health check and snapshot capabilities - handle network detection for proper node communication - implement safe cleanup on process exit This enables running typesense instances in test environments with proper lifecycle management. * feat(typesense): add global manager with environment configuration - create singleton `globalTypesenseManager` instance - implement `startTypesenseServer` function to initialize nodes - add `restartTypesenseServerFresh` for clean restarts - create `fetchNode` utility for API interactions - integrate environment configuration using t3-oss/env-core - set up environment variables for binary paths and directories This provides a centralized interface for managing typesense instances across tests. * test(env): add validation tests for environment configuration - add tests for environment variable validation using t3-oss/env-core - verify validation fails when required variables are missing - confirm validation passes with all required variables - test optional variable handling with TYPESENSE_SNAPSHOT_PATH - ensure proper error throwing behavior for various configurations This ensures robust environment validation for typesense test setup. * test(typesense): add integration tests for server lifecycle - implement test for server startup with multi-node verification - add test for restarting server with clean state - verify node configurations match expected port and directory settings - test collection creation and persistence between operations - validate collection data is cleared after restart * refactor(typesense): extract node directory mapping to separate method - extract `mapNodesToDirectories` method to improve code maintainability - reuse this method in `createDataDirectories` function - simplify directory mapping logic by using the new helper method * feat(typesense): add option to skip data directory cleanup - add `SetupNodesOptions` interface with `skipCleanup` option - modify `setupNodes` method to accept optional parameters - implement conditional logic to skip data directory cleanup when specified - reuse `mapNodesToDirectories` helper method for directory mapping * feat(utils): add URL construction utility - implement typed `UrlString` pattern with protocol, domain, port and path - add `constructUrl` helper function for building URLs with endpoints and params - create type definitions for URL components (Protocol, Domain, Port, Path) - export the new utility alongside existing functions * feat(typesense): add server restart with data preservation - implement `restartTypesenseServer` function that preserves data directories - update `startTypesenseServer` to accept optional configuration parameters - import `SetupNodesOptions` type to enable skipCleanup functionality - add 10-second delay with progress indicator during cleanup proces * feat(api): enhance fetchNode with URL construction and error handling - integrate `constructUrl` utility for building API request URLs - add support for query parameters in API requests - improve error handling with detailed HTTP error messages - add type safety with generic query parameters support - properly format endpoint paths with consistent leading slashes * test: add test case for restart with data preservation - add test for `restartTypesenseServer()` that verifies data persistence - import the non-fresh restart function from global manager - verify collection persistence across server restarts - check node configuration consistency before and after restart * feat: add configurable wait time to restart functions - add `waitForSeconds` parameter with default of 10 to both restart functions - replace hardcoded 10 second delay with configurable parameter - update log message to display dynamic wait time - ensure backward compatibility by making parameter optional * docs: add jsdom for global functions * feat(env): add optional IP address configuration parameter - add `TYPESENSE_IP_ADDRESS` as optional environment variable - update typesense manager initialization with IP address parameter - pass IP configuration to process manager constructor * perf: remove unnecessary delay in server startup sequence - remove 8-second artificial delay from startup process - keep health check verification as safety mechanism - improve test execution speed by eliminating wait time * fix: implement proper async process termination - replace synchronous `dispose()` with async promise-based implementation - add proper exit event handling with cleanup for both processes - prevent resource leaks by adding timeout clearing on exit - add detailed logging for process termination - fix type imports to improve code organization * perf: remove default wait time from restart procedure - change default `waitForSeconds` from 10 to 0 in `restartTypesenseServer` - eliminate unnecessary delay between process termination and restart - maintain parameter for cases where wait time is needed * perf: remove all wait times from restart operations - remove `waitForSeconds` parameter and functionality from both restart functions - eliminate delay import as it's no longer needed - remove 10-second wait in process manager restart method - simplify restart logic for more efficient test execution * perf: shorten delay before querying the master node * fix(client): adjust client retry parameters for typesense process - reduce `retryIntervalSeconds` from 10 to 3 seconds - increase `numRetries` from 6 to 20 attempts * chore: add openai and faker to deps * feat: implement openai proxy interceptor for testing - add new `openai.ts` module with proxy server functionality - implement mock response handling for openai api endpoints - support dynamic configuration of embedding dimensions - add self-signed certificate generation for https connections * feat: add environment variable for embedding dimensions - add `TYPESENSE_NUM_DIM` configuration with default value of 256 - integrate with environment validation schema in typesense manager * fix(env): enable empty string to undefined conversion in env parser - add `emptyStringAsUndefined: true` option to environment config - ensures empty environment variables are treated as undefined values * fix(manager): use default snapshot path when not specified - add fallback logic for snapshot path configuration - set default path as subdirectory within working directory - improve initialization with explicit variable assignment * refactor(manager): share spinner instance between components - extract `ora()` instance to separate variable - reuse spinner across manager initialization - prepare for sharing spinner with other components * feat: initialize and export openai proxy instance - create openai proxy with shared spinner instance - configure proxy with environment settings - export proxy for test suite consumption * feat(manager): add function to properly shutdown typesense server - implement `closeDownTypesenseServer` function - dispose all process instances and clean up resources - export function for test suite teardown procedures * feat(fetch): implement retry mechanism for node fetch operations - add automatic retry logic to `fetchNode` function - support configurable retry count and delay intervals - improve error handling with detailed failure messages - reorganize function parameters with dedicated interface * test: add cleanup handler for test server resources - implement `afterAll` hook to shutdown typesense server - use new `closeDownTypesenseServer` function for proper cleanup - prevent resource leaks between test runs * build(tests): disable parallel test execution - set `fileParallelism` to false to run tests sequentially - configure sequence options to maintain test order - prevent test interference when sharing typesense resources * test: add conversation model persistence across node restarts - implement test for conversation model availability after rotation - verify model configuration is preserved when nodes restart - initialize and cleanup openai proxy for conversation testing - create necessary collections and conversation store * test: verify openai embedding dimensions configuration - add test for embedding vector dimensions persistence - validate dimensions match environment configuration - confirm settings survive server restarts - integrate mock openai proxy for embedding tests * test: test snapshot functionality - add test to verify snapshot creation process - confirm snapshot files are correctly stored in configured location - validate document indexing and collection creation before snapshot - check for snapshot directory and file existence * refactor(benchmark): improve process management and add FS utilities - refactor `TypesenseProcessManager` to use proper error handling with `Result` types - replace direct fs operations with safer utilities from new `fs.ts` module - improve process disposal with proper async handling and event listeners - add network interface detection for better peering address resolution - modify k6 benchmark collection creation to use client directly - enhance logging with m * refactor(benchmark): rename benchmark function to `perform` * refactor(benchmark): extract file system utilities to dedicated module - move `getPlatform` function from `services/fs.ts` to new `utils/fs.ts` file - add new file system utility functions for safer FS operations - implement `exists`, `safeRm`, `safeMakeOrEmptyDir`, and `safeEmptyDir` with proper error handling - use `ResultAsync` from neverthrow for consistent error handling pattern - provide strongly typed interfaces for all FS operations * refactor(benchmark): reorganize utility functions for better organization - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` module - add `constructUrl` function with strongly typed parameters in `utils/base.ts` - implement safe file system operations with proper error h * refactor(benchmark): reorganize utilities and improve service architecture - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - update imports across files to reference new utility locations * feat(benchmark): reorganize utilities and add centralized service management - create new `global.ts` module for centralized Typesense server and OpenAI proxy management - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` utility module - add type-safe `constructUrl` function and network fetch utilities - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - implement environment variable management with t3-oss/env-core - add server lifecycle management functions (start, restart, close) - enhance error handling with consistent `ResultAsync` pattern throughout - improve TypesenseProcessManager with better health checks and network detection - update imports across all affected files * chore(benchmark): add t3-oss/env * refactor: remove integration tests from commands - remove `tests.ts` file containing integration test command (712 lines) - remove test command registration from `index.ts` - remove test command import from `index.ts` * chore(benchmark): add dotenv * refactor: relocate and refactor test files - move test files from `tests/tests/` to `benchmark/test/` - move vitest config from `tests/` to `benchmark/` - update import paths to match new directory structure - fix optional chaining in openai-embedding test - remove `tests.ts` command file (previous commit) * ci: change testing command to native pnpm script * build(vitest): configure setup function to ensure working-dir exists * ci: fix env vars for tests * ci: remove unecessary build step on tests * chore: bump typesense-js * feat(fetch): add typesense endpoint type definitions - Add `Endpoints` interface mapping api paths to http methods - Import typesense type definitions for collections, documents, and operations - Add utility types for path transformation and endpoint response inference - Improve type safety for api interactions in benchmark module * refactor(benchmark): implement type-safe api client with endpoint inference - Update `FetchNodeParams` interface to use typed endpoint definitions - Modify `fetchNode` function to infer request/response types from endpoint schema - Remove explicit type parameters from `fetchNode` calls in tests - Add conditional type mapping for body and query parameters based on endpoint - Improve type safety by eliminating manual type annotations * feat(fetch): add manual document generic passing by prefixed `~type` key - Avoid having to define all 3 generics by adding a prefixed `~type` key in the `FetchNode` parameters schema, so Typescript will infer the document type based on that parameter * fix(tests): remove unused generic type params in tests | 1 年前 | |
Testing framework (#2344) * chore(tests): init test dir * chore(tests): add neverthrow * chore(tests): add chalk * feat(logger): add logger for tests * chore(tests): add zod * chore(tests): add types for node * feat(error): add error handling utils * chore(tests): add fs-extra * chore(tests): add execa * feat(utils): add utility functions for async operations - add `isStringifiable` function to check if data can be converted to string - add `delay` function that returns a promise wrapped in ResultAsync - add `safeExeca` function to execute shell commands safely - export all utility functions for use throughout the codebase These utilities improve error handling and provide type-safe async operations. * chore(tests): add eslint * chore(tests): bump vitest * chore(tests): add dotenv * build: add vitest config * chore(tests): add ianvs prettier sort plugin * build: add prettier config * chore(tests): add ora spinner * chore(tests): add typesense-js * chore(tests): add t3 env core * feat(platform): add getPlatform function for OS detection - add `getPlatform()` function that returns platform flag based on architecture - implement logic to detect x64, arm and arm64 architectures - default to `linux/amd64` for unrecognized architectures * feat(typesense): add process manager for test environment - implement `TypesenseProcessController` to manage individual process instances - create `TypesenseProcessManager` class to coordinate multiple processes - add support for multi-node typesense cluster configuration - implement methods for process lifecycle (start, stop, restart) - add health check and snapshot capabilities - handle network detection for proper node communication - implement safe cleanup on process exit This enables running typesense instances in test environments with proper lifecycle management. * feat(typesense): add global manager with environment configuration - create singleton `globalTypesenseManager` instance - implement `startTypesenseServer` function to initialize nodes - add `restartTypesenseServerFresh` for clean restarts - create `fetchNode` utility for API interactions - integrate environment configuration using t3-oss/env-core - set up environment variables for binary paths and directories This provides a centralized interface for managing typesense instances across tests. * test(env): add validation tests for environment configuration - add tests for environment variable validation using t3-oss/env-core - verify validation fails when required variables are missing - confirm validation passes with all required variables - test optional variable handling with TYPESENSE_SNAPSHOT_PATH - ensure proper error throwing behavior for various configurations This ensures robust environment validation for typesense test setup. * test(typesense): add integration tests for server lifecycle - implement test for server startup with multi-node verification - add test for restarting server with clean state - verify node configurations match expected port and directory settings - test collection creation and persistence between operations - validate collection data is cleared after restart * refactor(typesense): extract node directory mapping to separate method - extract `mapNodesToDirectories` method to improve code maintainability - reuse this method in `createDataDirectories` function - simplify directory mapping logic by using the new helper method * feat(typesense): add option to skip data directory cleanup - add `SetupNodesOptions` interface with `skipCleanup` option - modify `setupNodes` method to accept optional parameters - implement conditional logic to skip data directory cleanup when specified - reuse `mapNodesToDirectories` helper method for directory mapping * feat(utils): add URL construction utility - implement typed `UrlString` pattern with protocol, domain, port and path - add `constructUrl` helper function for building URLs with endpoints and params - create type definitions for URL components (Protocol, Domain, Port, Path) - export the new utility alongside existing functions * feat(typesense): add server restart with data preservation - implement `restartTypesenseServer` function that preserves data directories - update `startTypesenseServer` to accept optional configuration parameters - import `SetupNodesOptions` type to enable skipCleanup functionality - add 10-second delay with progress indicator during cleanup proces * feat(api): enhance fetchNode with URL construction and error handling - integrate `constructUrl` utility for building API request URLs - add support for query parameters in API requests - improve error handling with detailed HTTP error messages - add type safety with generic query parameters support - properly format endpoint paths with consistent leading slashes * test: add test case for restart with data preservation - add test for `restartTypesenseServer()` that verifies data persistence - import the non-fresh restart function from global manager - verify collection persistence across server restarts - check node configuration consistency before and after restart * feat: add configurable wait time to restart functions - add `waitForSeconds` parameter with default of 10 to both restart functions - replace hardcoded 10 second delay with configurable parameter - update log message to display dynamic wait time - ensure backward compatibility by making parameter optional * docs: add jsdom for global functions * feat(env): add optional IP address configuration parameter - add `TYPESENSE_IP_ADDRESS` as optional environment variable - update typesense manager initialization with IP address parameter - pass IP configuration to process manager constructor * perf: remove unnecessary delay in server startup sequence - remove 8-second artificial delay from startup process - keep health check verification as safety mechanism - improve test execution speed by eliminating wait time * fix: implement proper async process termination - replace synchronous `dispose()` with async promise-based implementation - add proper exit event handling with cleanup for both processes - prevent resource leaks by adding timeout clearing on exit - add detailed logging for process termination - fix type imports to improve code organization * perf: remove default wait time from restart procedure - change default `waitForSeconds` from 10 to 0 in `restartTypesenseServer` - eliminate unnecessary delay between process termination and restart - maintain parameter for cases where wait time is needed * perf: remove all wait times from restart operations - remove `waitForSeconds` parameter and functionality from both restart functions - eliminate delay import as it's no longer needed - remove 10-second wait in process manager restart method - simplify restart logic for more efficient test execution * perf: shorten delay before querying the master node * fix(client): adjust client retry parameters for typesense process - reduce `retryIntervalSeconds` from 10 to 3 seconds - increase `numRetries` from 6 to 20 attempts * chore: add openai and faker to deps * feat: implement openai proxy interceptor for testing - add new `openai.ts` module with proxy server functionality - implement mock response handling for openai api endpoints - support dynamic configuration of embedding dimensions - add self-signed certificate generation for https connections * feat: add environment variable for embedding dimensions - add `TYPESENSE_NUM_DIM` configuration with default value of 256 - integrate with environment validation schema in typesense manager * fix(env): enable empty string to undefined conversion in env parser - add `emptyStringAsUndefined: true` option to environment config - ensures empty environment variables are treated as undefined values * fix(manager): use default snapshot path when not specified - add fallback logic for snapshot path configuration - set default path as subdirectory within working directory - improve initialization with explicit variable assignment * refactor(manager): share spinner instance between components - extract `ora()` instance to separate variable - reuse spinner across manager initialization - prepare for sharing spinner with other components * feat: initialize and export openai proxy instance - create openai proxy with shared spinner instance - configure proxy with environment settings - export proxy for test suite consumption * feat(manager): add function to properly shutdown typesense server - implement `closeDownTypesenseServer` function - dispose all process instances and clean up resources - export function for test suite teardown procedures * feat(fetch): implement retry mechanism for node fetch operations - add automatic retry logic to `fetchNode` function - support configurable retry count and delay intervals - improve error handling with detailed failure messages - reorganize function parameters with dedicated interface * test: add cleanup handler for test server resources - implement `afterAll` hook to shutdown typesense server - use new `closeDownTypesenseServer` function for proper cleanup - prevent resource leaks between test runs * build(tests): disable parallel test execution - set `fileParallelism` to false to run tests sequentially - configure sequence options to maintain test order - prevent test interference when sharing typesense resources * test: add conversation model persistence across node restarts - implement test for conversation model availability after rotation - verify model configuration is preserved when nodes restart - initialize and cleanup openai proxy for conversation testing - create necessary collections and conversation store * test: verify openai embedding dimensions configuration - add test for embedding vector dimensions persistence - validate dimensions match environment configuration - confirm settings survive server restarts - integrate mock openai proxy for embedding tests * test: test snapshot functionality - add test to verify snapshot creation process - confirm snapshot files are correctly stored in configured location - validate document indexing and collection creation before snapshot - check for snapshot directory and file existence * refactor(benchmark): improve process management and add FS utilities - refactor `TypesenseProcessManager` to use proper error handling with `Result` types - replace direct fs operations with safer utilities from new `fs.ts` module - improve process disposal with proper async handling and event listeners - add network interface detection for better peering address resolution - modify k6 benchmark collection creation to use client directly - enhance logging with m * refactor(benchmark): rename benchmark function to `perform` * refactor(benchmark): extract file system utilities to dedicated module - move `getPlatform` function from `services/fs.ts` to new `utils/fs.ts` file - add new file system utility functions for safer FS operations - implement `exists`, `safeRm`, `safeMakeOrEmptyDir`, and `safeEmptyDir` with proper error handling - use `ResultAsync` from neverthrow for consistent error handling pattern - provide strongly typed interfaces for all FS operations * refactor(benchmark): reorganize utility functions for better organization - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` module - add `constructUrl` function with strongly typed parameters in `utils/base.ts` - implement safe file system operations with proper error h * refactor(benchmark): reorganize utilities and improve service architecture - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - update imports across files to reference new utility locations * feat(benchmark): reorganize utilities and add centralized service management - create new `global.ts` module for centralized Typesense server and OpenAI proxy management - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` utility module - add type-safe `constructUrl` function and network fetch utilities - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - implement environment variable management with t3-oss/env-core - add server lifecycle management functions (start, restart, close) - enhance error handling with consistent `ResultAsync` pattern throughout - improve TypesenseProcessManager with better health checks and network detection - update imports across all affected files * chore(benchmark): add t3-oss/env * refactor: remove integration tests from commands - remove `tests.ts` file containing integration test command (712 lines) - remove test command registration from `index.ts` - remove test command import from `index.ts` * chore(benchmark): add dotenv * refactor: relocate and refactor test files - move test files from `tests/tests/` to `benchmark/test/` - move vitest config from `tests/` to `benchmark/` - update import paths to match new directory structure - fix optional chaining in openai-embedding test - remove `tests.ts` command file (previous commit) * ci: change testing command to native pnpm script * build(vitest): configure setup function to ensure working-dir exists * ci: fix env vars for tests * ci: remove unecessary build step on tests * chore: bump typesense-js * feat(fetch): add typesense endpoint type definitions - Add `Endpoints` interface mapping api paths to http methods - Import typesense type definitions for collections, documents, and operations - Add utility types for path transformation and endpoint response inference - Improve type safety for api interactions in benchmark module * refactor(benchmark): implement type-safe api client with endpoint inference - Update `FetchNodeParams` interface to use typed endpoint definitions - Modify `fetchNode` function to infer request/response types from endpoint schema - Remove explicit type parameters from `fetchNode` calls in tests - Add conditional type mapping for body and query parameters based on endpoint - Improve type safety by eliminating manual type annotations * feat(fetch): add manual document generic passing by prefixed `~type` key - Avoid having to define all 3 generics by adding a prefixed `~type` key in the `FetchNode` parameters schema, so Typescript will infer the document type based on that parameter * fix(tests): remove unused generic type params in tests | 1 年前 | |
Testing framework (#2344) * chore(tests): init test dir * chore(tests): add neverthrow * chore(tests): add chalk * feat(logger): add logger for tests * chore(tests): add zod * chore(tests): add types for node * feat(error): add error handling utils * chore(tests): add fs-extra * chore(tests): add execa * feat(utils): add utility functions for async operations - add `isStringifiable` function to check if data can be converted to string - add `delay` function that returns a promise wrapped in ResultAsync - add `safeExeca` function to execute shell commands safely - export all utility functions for use throughout the codebase These utilities improve error handling and provide type-safe async operations. * chore(tests): add eslint * chore(tests): bump vitest * chore(tests): add dotenv * build: add vitest config * chore(tests): add ianvs prettier sort plugin * build: add prettier config * chore(tests): add ora spinner * chore(tests): add typesense-js * chore(tests): add t3 env core * feat(platform): add getPlatform function for OS detection - add `getPlatform()` function that returns platform flag based on architecture - implement logic to detect x64, arm and arm64 architectures - default to `linux/amd64` for unrecognized architectures * feat(typesense): add process manager for test environment - implement `TypesenseProcessController` to manage individual process instances - create `TypesenseProcessManager` class to coordinate multiple processes - add support for multi-node typesense cluster configuration - implement methods for process lifecycle (start, stop, restart) - add health check and snapshot capabilities - handle network detection for proper node communication - implement safe cleanup on process exit This enables running typesense instances in test environments with proper lifecycle management. * feat(typesense): add global manager with environment configuration - create singleton `globalTypesenseManager` instance - implement `startTypesenseServer` function to initialize nodes - add `restartTypesenseServerFresh` for clean restarts - create `fetchNode` utility for API interactions - integrate environment configuration using t3-oss/env-core - set up environment variables for binary paths and directories This provides a centralized interface for managing typesense instances across tests. * test(env): add validation tests for environment configuration - add tests for environment variable validation using t3-oss/env-core - verify validation fails when required variables are missing - confirm validation passes with all required variables - test optional variable handling with TYPESENSE_SNAPSHOT_PATH - ensure proper error throwing behavior for various configurations This ensures robust environment validation for typesense test setup. * test(typesense): add integration tests for server lifecycle - implement test for server startup with multi-node verification - add test for restarting server with clean state - verify node configurations match expected port and directory settings - test collection creation and persistence between operations - validate collection data is cleared after restart * refactor(typesense): extract node directory mapping to separate method - extract `mapNodesToDirectories` method to improve code maintainability - reuse this method in `createDataDirectories` function - simplify directory mapping logic by using the new helper method * feat(typesense): add option to skip data directory cleanup - add `SetupNodesOptions` interface with `skipCleanup` option - modify `setupNodes` method to accept optional parameters - implement conditional logic to skip data directory cleanup when specified - reuse `mapNodesToDirectories` helper method for directory mapping * feat(utils): add URL construction utility - implement typed `UrlString` pattern with protocol, domain, port and path - add `constructUrl` helper function for building URLs with endpoints and params - create type definitions for URL components (Protocol, Domain, Port, Path) - export the new utility alongside existing functions * feat(typesense): add server restart with data preservation - implement `restartTypesenseServer` function that preserves data directories - update `startTypesenseServer` to accept optional configuration parameters - import `SetupNodesOptions` type to enable skipCleanup functionality - add 10-second delay with progress indicator during cleanup proces * feat(api): enhance fetchNode with URL construction and error handling - integrate `constructUrl` utility for building API request URLs - add support for query parameters in API requests - improve error handling with detailed HTTP error messages - add type safety with generic query parameters support - properly format endpoint paths with consistent leading slashes * test: add test case for restart with data preservation - add test for `restartTypesenseServer()` that verifies data persistence - import the non-fresh restart function from global manager - verify collection persistence across server restarts - check node configuration consistency before and after restart * feat: add configurable wait time to restart functions - add `waitForSeconds` parameter with default of 10 to both restart functions - replace hardcoded 10 second delay with configurable parameter - update log message to display dynamic wait time - ensure backward compatibility by making parameter optional * docs: add jsdom for global functions * feat(env): add optional IP address configuration parameter - add `TYPESENSE_IP_ADDRESS` as optional environment variable - update typesense manager initialization with IP address parameter - pass IP configuration to process manager constructor * perf: remove unnecessary delay in server startup sequence - remove 8-second artificial delay from startup process - keep health check verification as safety mechanism - improve test execution speed by eliminating wait time * fix: implement proper async process termination - replace synchronous `dispose()` with async promise-based implementation - add proper exit event handling with cleanup for both processes - prevent resource leaks by adding timeout clearing on exit - add detailed logging for process termination - fix type imports to improve code organization * perf: remove default wait time from restart procedure - change default `waitForSeconds` from 10 to 0 in `restartTypesenseServer` - eliminate unnecessary delay between process termination and restart - maintain parameter for cases where wait time is needed * perf: remove all wait times from restart operations - remove `waitForSeconds` parameter and functionality from both restart functions - eliminate delay import as it's no longer needed - remove 10-second wait in process manager restart method - simplify restart logic for more efficient test execution * perf: shorten delay before querying the master node * fix(client): adjust client retry parameters for typesense process - reduce `retryIntervalSeconds` from 10 to 3 seconds - increase `numRetries` from 6 to 20 attempts * chore: add openai and faker to deps * feat: implement openai proxy interceptor for testing - add new `openai.ts` module with proxy server functionality - implement mock response handling for openai api endpoints - support dynamic configuration of embedding dimensions - add self-signed certificate generation for https connections * feat: add environment variable for embedding dimensions - add `TYPESENSE_NUM_DIM` configuration with default value of 256 - integrate with environment validation schema in typesense manager * fix(env): enable empty string to undefined conversion in env parser - add `emptyStringAsUndefined: true` option to environment config - ensures empty environment variables are treated as undefined values * fix(manager): use default snapshot path when not specified - add fallback logic for snapshot path configuration - set default path as subdirectory within working directory - improve initialization with explicit variable assignment * refactor(manager): share spinner instance between components - extract `ora()` instance to separate variable - reuse spinner across manager initialization - prepare for sharing spinner with other components * feat: initialize and export openai proxy instance - create openai proxy with shared spinner instance - configure proxy with environment settings - export proxy for test suite consumption * feat(manager): add function to properly shutdown typesense server - implement `closeDownTypesenseServer` function - dispose all process instances and clean up resources - export function for test suite teardown procedures * feat(fetch): implement retry mechanism for node fetch operations - add automatic retry logic to `fetchNode` function - support configurable retry count and delay intervals - improve error handling with detailed failure messages - reorganize function parameters with dedicated interface * test: add cleanup handler for test server resources - implement `afterAll` hook to shutdown typesense server - use new `closeDownTypesenseServer` function for proper cleanup - prevent resource leaks between test runs * build(tests): disable parallel test execution - set `fileParallelism` to false to run tests sequentially - configure sequence options to maintain test order - prevent test interference when sharing typesense resources * test: add conversation model persistence across node restarts - implement test for conversation model availability after rotation - verify model configuration is preserved when nodes restart - initialize and cleanup openai proxy for conversation testing - create necessary collections and conversation store * test: verify openai embedding dimensions configuration - add test for embedding vector dimensions persistence - validate dimensions match environment configuration - confirm settings survive server restarts - integrate mock openai proxy for embedding tests * test: test snapshot functionality - add test to verify snapshot creation process - confirm snapshot files are correctly stored in configured location - validate document indexing and collection creation before snapshot - check for snapshot directory and file existence * refactor(benchmark): improve process management and add FS utilities - refactor `TypesenseProcessManager` to use proper error handling with `Result` types - replace direct fs operations with safer utilities from new `fs.ts` module - improve process disposal with proper async handling and event listeners - add network interface detection for better peering address resolution - modify k6 benchmark collection creation to use client directly - enhance logging with m * refactor(benchmark): rename benchmark function to `perform` * refactor(benchmark): extract file system utilities to dedicated module - move `getPlatform` function from `services/fs.ts` to new `utils/fs.ts` file - add new file system utility functions for safer FS operations - implement `exists`, `safeRm`, `safeMakeOrEmptyDir`, and `safeEmptyDir` with proper error handling - use `ResultAsync` from neverthrow for consistent error handling pattern - provide strongly typed interfaces for all FS operations * refactor(benchmark): reorganize utility functions for better organization - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` module - add `constructUrl` function with strongly typed parameters in `utils/base.ts` - implement safe file system operations with proper error h * refactor(benchmark): reorganize utilities and improve service architecture - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - update imports across files to reference new utility locations * feat(benchmark): reorganize utilities and add centralized service management - create new `global.ts` module for centralized Typesense server and OpenAI proxy management - extract file system utilities from `services/fs.ts` to new `utils/fs.ts` module - move `delay` function from `utils/execa.ts` to new `utils/base.ts` utility module - add type-safe `constructUrl` function and network fetch utilities - rename `OpenAIProxyService` to `OpenAIProxy` for naming consistency - implement environment variable management with t3-oss/env-core - add server lifecycle management functions (start, restart, close) - enhance error handling with consistent `ResultAsync` pattern throughout - improve TypesenseProcessManager with better health checks and network detection - update imports across all affected files * chore(benchmark): add t3-oss/env * refactor: remove integration tests from commands - remove `tests.ts` file containing integration test command (712 lines) - remove test command registration from `index.ts` - remove test command import from `index.ts` * chore(benchmark): add dotenv * refactor: relocate and refactor test files - move test files from `tests/tests/` to `benchmark/test/` - move vitest config from `tests/` to `benchmark/` - update import paths to match new directory structure - fix optional chaining in openai-embedding test - remove `tests.ts` command file (previous commit) * ci: change testing command to native pnpm script * build(vitest): configure setup function to ensure working-dir exists * ci: fix env vars for tests * ci: remove unecessary build step on tests * chore: bump typesense-js * feat(fetch): add typesense endpoint type definitions - Add `Endpoints` interface mapping api paths to http methods - Import typesense type definitions for collections, documents, and operations - Add utility types for path transformation and endpoint response inference - Improve type safety for api interactions in benchmark module * refactor(benchmark): implement type-safe api client with endpoint inference - Update `FetchNodeParams` interface to use typed endpoint definitions - Modify `fetchNode` function to infer request/response types from endpoint schema - Remove explicit type parameters from `fetchNode` calls in tests - Add conditional type mapping for body and query parameters based on endpoint - Improve type safety by eliminating manual type annotations * feat(fetch): add manual document generic passing by prefixed `~type` key - Avoid having to define all 3 generics by adding a prefixed `~type` key in the `FetchNode` parameters schema, so Typescript will infer the document type based on that parameter * fix(tests): remove unused generic type params in tests | 1 年前 |