@sixthsummit/ship-api 0.0.0-stage → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +605 -0
- package/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +58 -2
- package/cli/commands/add.js +537 -0
- package/cli/commands/contract.js +2 -0
- package/cli/commands/create.js +250 -0
- package/cli/commands/dev.js +227 -0
- package/cli/commands/doctor.js +286 -0
- package/cli/commands/generate.js +937 -0
- package/cli/commands/graph.js +2 -0
- package/cli/commands/migrate-orm.js +1171 -0
- package/cli/commands/update.js +37 -0
- package/cli/ship-api.js +285 -0
- package/lib/app/auth/AuthProvider.d.ts +91 -0
- package/lib/app/auth/AuthProvider.d.ts.map +1 -0
- package/lib/app/auth/AuthProvider.js +13 -0
- package/lib/app/auth/AuthProvider.js.map +1 -0
- package/lib/app/auth/adapters/firebase.d.ts +79 -0
- package/lib/app/auth/adapters/firebase.d.ts.map +1 -0
- package/lib/app/auth/adapters/firebase.js +122 -0
- package/lib/app/auth/adapters/firebase.js.map +1 -0
- package/lib/app/auth/adapters/jwtCookie.d.ts +55 -0
- package/lib/app/auth/adapters/jwtCookie.d.ts.map +1 -0
- package/lib/app/auth/adapters/jwtCookie.js +120 -0
- package/lib/app/auth/adapters/jwtCookie.js.map +1 -0
- package/lib/app/auth/index.d.ts +8 -0
- package/lib/app/auth/index.d.ts.map +1 -0
- package/lib/app/auth/index.js +7 -0
- package/lib/app/auth/index.js.map +1 -0
- package/lib/app/auth/jwt/AuthFlow.d.ts +94 -0
- package/lib/app/auth/jwt/AuthFlow.d.ts.map +1 -0
- package/lib/app/auth/jwt/AuthFlow.js +127 -0
- package/lib/app/auth/jwt/AuthFlow.js.map +1 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.d.ts +80 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.d.ts.map +1 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.js +134 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.js.map +1 -0
- package/lib/app/auth/jwt/JwtSigner.d.ts +123 -0
- package/lib/app/auth/jwt/JwtSigner.d.ts.map +1 -0
- package/lib/app/auth/jwt/JwtSigner.js +118 -0
- package/lib/app/auth/jwt/JwtSigner.js.map +1 -0
- package/lib/app/auth/jwt/RefreshTokenStore.d.ts +97 -0
- package/lib/app/auth/jwt/RefreshTokenStore.d.ts.map +1 -0
- package/lib/app/auth/jwt/RefreshTokenStore.js +122 -0
- package/lib/app/auth/jwt/RefreshTokenStore.js.map +1 -0
- package/lib/app/auth/permissionDefinition.d.ts +20 -0
- package/lib/app/auth/permissionDefinition.d.ts.map +1 -0
- package/lib/app/auth/permissionDefinition.js +2 -0
- package/lib/app/auth/permissionDefinition.js.map +1 -0
- package/lib/app/context/RequestContext.d.ts +59 -0
- package/lib/app/context/RequestContext.d.ts.map +1 -0
- package/lib/app/context/RequestContext.js +25 -0
- package/lib/app/context/RequestContext.js.map +1 -0
- package/lib/app/db/QueryOptions.d.ts +82 -0
- package/lib/app/db/QueryOptions.d.ts.map +1 -0
- package/lib/app/db/QueryOptions.js +37 -0
- package/lib/app/db/QueryOptions.js.map +1 -0
- package/lib/app/db/baseFields.d.ts +60 -0
- package/lib/app/db/baseFields.d.ts.map +1 -0
- package/lib/app/db/baseFields.js +54 -0
- package/lib/app/db/baseFields.js.map +1 -0
- package/lib/app/db/buildWhere.d.ts +22 -0
- package/lib/app/db/buildWhere.d.ts.map +1 -0
- package/lib/app/db/buildWhere.js +75 -0
- package/lib/app/db/buildWhere.js.map +1 -0
- package/lib/app/db/client.d.ts +111 -0
- package/lib/app/db/client.d.ts.map +1 -0
- package/lib/app/db/client.js +99 -0
- package/lib/app/db/client.js.map +1 -0
- package/lib/app/db/tenantScoped.d.ts +59 -0
- package/lib/app/db/tenantScoped.d.ts.map +1 -0
- package/lib/app/db/tenantScoped.js +54 -0
- package/lib/app/db/tenantScoped.js.map +1 -0
- package/lib/app/db/transaction.d.ts +58 -0
- package/lib/app/db/transaction.d.ts.map +1 -0
- package/lib/app/db/transaction.js +106 -0
- package/lib/app/db/transaction.js.map +1 -0
- package/lib/app/health/HealthCheck.d.ts +121 -0
- package/lib/app/health/HealthCheck.d.ts.map +1 -0
- package/lib/app/health/HealthCheck.js +151 -0
- package/lib/app/health/HealthCheck.js.map +1 -0
- package/lib/app/health/redisHealthCheck.d.ts +14 -0
- package/lib/app/health/redisHealthCheck.d.ts.map +1 -0
- package/lib/app/health/redisHealthCheck.js +21 -0
- package/lib/app/health/redisHealthCheck.js.map +1 -0
- package/lib/app/lifecycle/Bootstrapper.d.ts +92 -0
- package/lib/app/lifecycle/Bootstrapper.d.ts.map +1 -0
- package/lib/app/lifecycle/Bootstrapper.js +99 -0
- package/lib/app/lifecycle/Bootstrapper.js.map +1 -0
- package/lib/app/registry/routes.d.ts +89 -0
- package/lib/app/registry/routes.d.ts.map +1 -0
- package/lib/app/registry/routes.js +72 -0
- package/lib/app/registry/routes.js.map +1 -0
- package/lib/app/services/DrizzleEntityService.d.ts +123 -0
- package/lib/app/services/DrizzleEntityService.d.ts.map +1 -0
- package/lib/app/services/DrizzleEntityService.js +342 -0
- package/lib/app/services/DrizzleEntityService.js.map +1 -0
- package/lib/app/services/RedisProvider.d.ts +52 -0
- package/lib/app/services/RedisProvider.d.ts.map +1 -0
- package/lib/app/services/RedisProvider.js +75 -0
- package/lib/app/services/RedisProvider.js.map +1 -0
- package/lib/app/services/cache/Cache.d.ts +70 -0
- package/lib/app/services/cache/Cache.d.ts.map +1 -0
- package/lib/app/services/cache/Cache.js +18 -0
- package/lib/app/services/cache/Cache.js.map +1 -0
- package/lib/app/services/cache/InMemoryCache.d.ts +35 -0
- package/lib/app/services/cache/InMemoryCache.d.ts.map +1 -0
- package/lib/app/services/cache/InMemoryCache.js +76 -0
- package/lib/app/services/cache/InMemoryCache.js.map +1 -0
- package/lib/app/services/cache/RedisCache.d.ts +99 -0
- package/lib/app/services/cache/RedisCache.d.ts.map +1 -0
- package/lib/app/services/cache/RedisCache.js +150 -0
- package/lib/app/services/cache/RedisCache.js.map +1 -0
- package/lib/app/services/cache/cached.d.ts +30 -0
- package/lib/app/services/cache/cached.d.ts.map +1 -0
- package/lib/app/services/cache/cached.js +38 -0
- package/lib/app/services/cache/cached.js.map +1 -0
- package/lib/app/services/cache/index.d.ts +5 -0
- package/lib/app/services/cache/index.d.ts.map +1 -0
- package/lib/app/services/cache/index.js +4 -0
- package/lib/app/services/cache/index.js.map +1 -0
- package/lib/app/services/cron/defineCron.d.ts +57 -0
- package/lib/app/services/cron/defineCron.d.ts.map +1 -0
- package/lib/app/services/cron/defineCron.js +15 -0
- package/lib/app/services/cron/defineCron.js.map +1 -0
- package/lib/app/services/cron/index.d.ts +2 -0
- package/lib/app/services/cron/index.d.ts.map +1 -0
- package/lib/app/services/cron/index.js +2 -0
- package/lib/app/services/cron/index.js.map +1 -0
- package/lib/app/services/hooks/LifecycleHooks.d.ts +61 -0
- package/lib/app/services/hooks/LifecycleHooks.d.ts.map +1 -0
- package/lib/app/services/hooks/LifecycleHooks.js +85 -0
- package/lib/app/services/hooks/LifecycleHooks.js.map +1 -0
- package/lib/app/services/jobs/JobsManager.d.ts +67 -0
- package/lib/app/services/jobs/JobsManager.d.ts.map +1 -0
- package/lib/app/services/jobs/JobsManager.js +121 -0
- package/lib/app/services/jobs/JobsManager.js.map +1 -0
- package/lib/app/services/jobs/bullBoard.d.ts +72 -0
- package/lib/app/services/jobs/bullBoard.d.ts.map +1 -0
- package/lib/app/services/jobs/bullBoard.js +96 -0
- package/lib/app/services/jobs/bullBoard.js.map +1 -0
- package/lib/app/services/jobs/defineJob.d.ts +81 -0
- package/lib/app/services/jobs/defineJob.d.ts.map +1 -0
- package/lib/app/services/jobs/defineJob.js +49 -0
- package/lib/app/services/jobs/defineJob.js.map +1 -0
- package/lib/app/services/jobs/index.d.ts +4 -0
- package/lib/app/services/jobs/index.d.ts.map +1 -0
- package/lib/app/services/jobs/index.js +4 -0
- package/lib/app/services/jobs/index.js.map +1 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.d.ts +23 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.d.ts.map +1 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.js +51 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.js.map +1 -0
- package/lib/app/services/rateLimit/RateLimitBackend.d.ts +41 -0
- package/lib/app/services/rateLimit/RateLimitBackend.d.ts.map +1 -0
- package/lib/app/services/rateLimit/RateLimitBackend.js +19 -0
- package/lib/app/services/rateLimit/RateLimitBackend.js.map +1 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.d.ts +16 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.d.ts.map +1 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.js +80 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.js.map +1 -0
- package/lib/app/services/rateLimit/index.d.ts +4 -0
- package/lib/app/services/rateLimit/index.d.ts.map +1 -0
- package/lib/app/services/rateLimit/index.js +3 -0
- package/lib/app/services/rateLimit/index.js.map +1 -0
- package/lib/app/services/storage/DiskStorageAdapter.d.ts +62 -0
- package/lib/app/services/storage/DiskStorageAdapter.d.ts.map +1 -0
- package/lib/app/services/storage/DiskStorageAdapter.js +295 -0
- package/lib/app/services/storage/DiskStorageAdapter.js.map +1 -0
- package/lib/app/services/storage/GCSStorageAdapter.d.ts +44 -0
- package/lib/app/services/storage/GCSStorageAdapter.d.ts.map +1 -0
- package/lib/app/services/storage/GCSStorageAdapter.js +133 -0
- package/lib/app/services/storage/GCSStorageAdapter.js.map +1 -0
- package/lib/app/services/storage/S3StorageAdapter.d.ts +57 -0
- package/lib/app/services/storage/S3StorageAdapter.d.ts.map +1 -0
- package/lib/app/services/storage/S3StorageAdapter.js +162 -0
- package/lib/app/services/storage/S3StorageAdapter.js.map +1 -0
- package/lib/app/services/storage/StorageService.d.ts +88 -0
- package/lib/app/services/storage/StorageService.d.ts.map +1 -0
- package/lib/app/services/storage/StorageService.js +18 -0
- package/lib/app/services/storage/StorageService.js.map +1 -0
- package/lib/app/services/storage/index.d.ts +5 -0
- package/lib/app/services/storage/index.d.ts.map +1 -0
- package/lib/app/services/storage/index.js +4 -0
- package/lib/app/services/storage/index.js.map +1 -0
- package/lib/app/utils/ContextValidators.d.ts +46 -0
- package/lib/app/utils/ContextValidators.d.ts.map +1 -0
- package/lib/app/utils/ContextValidators.js +81 -0
- package/lib/app/utils/ContextValidators.js.map +1 -0
- package/lib/app/utils/defineEnv.d.ts +80 -0
- package/lib/app/utils/defineEnv.d.ts.map +1 -0
- package/lib/app/utils/defineEnv.js +95 -0
- package/lib/app/utils/defineEnv.js.map +1 -0
- package/lib/client.d.ts +139 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +98 -0
- package/lib/client.js.map +1 -0
- package/lib/contract/application.d.ts +3 -0
- package/lib/contract/application.d.ts.map +1 -0
- package/lib/contract/application.js +2 -0
- package/lib/contract/application.js.map +1 -0
- package/lib/contract/client.d.ts +3 -0
- package/lib/contract/client.d.ts.map +1 -0
- package/lib/contract/client.js +3 -0
- package/lib/contract/client.js.map +1 -0
- package/lib/contract/index.d.ts +3 -0
- package/lib/contract/index.d.ts.map +1 -0
- package/lib/contract/index.js +3 -0
- package/lib/contract/index.js.map +1 -0
- package/lib/contract/manifest.d.ts +3 -0
- package/lib/contract/manifest.d.ts.map +1 -0
- package/lib/contract/manifest.js +2 -0
- package/lib/contract/manifest.js.map +1 -0
- package/lib/contract/openapi.d.ts +3 -0
- package/lib/contract/openapi.d.ts.map +1 -0
- package/lib/contract/openapi.js +3 -0
- package/lib/contract/openapi.js.map +1 -0
- package/lib/contract/project.d.ts +3 -0
- package/lib/contract/project.d.ts.map +1 -0
- package/lib/contract/project.js +3 -0
- package/lib/contract/project.js.map +1 -0
- package/lib/contract/schema.d.ts +3 -0
- package/lib/contract/schema.d.ts.map +1 -0
- package/lib/contract/schema.js +3 -0
- package/lib/contract/schema.js.map +1 -0
- package/lib/drizzle/index.d.ts +3 -0
- package/lib/drizzle/index.d.ts.map +1 -0
- package/lib/drizzle/index.js +3 -0
- package/lib/drizzle/index.js.map +1 -0
- package/lib/hono/auth.d.ts +6 -0
- package/lib/hono/auth.d.ts.map +1 -0
- package/lib/hono/auth.js +54 -0
- package/lib/hono/auth.js.map +1 -0
- package/lib/hono/index.d.ts +4 -0
- package/lib/hono/index.d.ts.map +1 -0
- package/lib/hono/index.js +4 -0
- package/lib/hono/index.js.map +1 -0
- package/lib/http/app/createApp.d.ts +132 -0
- package/lib/http/app/createApp.d.ts.map +1 -0
- package/lib/http/app/createApp.js +215 -0
- package/lib/http/app/createApp.js.map +1 -0
- package/lib/http/app/devRoutes.d.ts +31 -0
- package/lib/http/app/devRoutes.d.ts.map +1 -0
- package/lib/http/app/devRoutes.js +145 -0
- package/lib/http/app/devRoutes.js.map +1 -0
- package/lib/http/app/errors.d.ts +45 -0
- package/lib/http/app/errors.d.ts.map +1 -0
- package/lib/http/app/errors.js +93 -0
- package/lib/http/app/errors.js.map +1 -0
- package/lib/http/app/health.d.ts +66 -0
- package/lib/http/app/health.d.ts.map +1 -0
- package/lib/http/app/health.js +104 -0
- package/lib/http/app/health.js.map +1 -0
- package/lib/http/errors/AppError.d.ts +10 -0
- package/lib/http/errors/AppError.d.ts.map +1 -0
- package/lib/http/errors/AppError.js +19 -0
- package/lib/http/errors/AppError.js.map +1 -0
- package/lib/http/errors/AuthenticationError.d.ts +8 -0
- package/lib/http/errors/AuthenticationError.d.ts.map +1 -0
- package/lib/http/errors/AuthenticationError.js +10 -0
- package/lib/http/errors/AuthenticationError.js.map +1 -0
- package/lib/http/errors/AuthorizationError.d.ts +8 -0
- package/lib/http/errors/AuthorizationError.d.ts.map +1 -0
- package/lib/http/errors/AuthorizationError.js +10 -0
- package/lib/http/errors/AuthorizationError.js.map +1 -0
- package/lib/http/errors/BadRequestError.d.ts +8 -0
- package/lib/http/errors/BadRequestError.d.ts.map +1 -0
- package/lib/http/errors/BadRequestError.js +10 -0
- package/lib/http/errors/BadRequestError.js.map +1 -0
- package/lib/http/errors/ConflictError.d.ts +8 -0
- package/lib/http/errors/ConflictError.d.ts.map +1 -0
- package/lib/http/errors/ConflictError.js +10 -0
- package/lib/http/errors/ConflictError.js.map +1 -0
- package/lib/http/errors/InternalServerError.d.ts +8 -0
- package/lib/http/errors/InternalServerError.d.ts.map +1 -0
- package/lib/http/errors/InternalServerError.js +10 -0
- package/lib/http/errors/InternalServerError.js.map +1 -0
- package/lib/http/errors/NotFoundError.d.ts +8 -0
- package/lib/http/errors/NotFoundError.d.ts.map +1 -0
- package/lib/http/errors/NotFoundError.js +10 -0
- package/lib/http/errors/NotFoundError.js.map +1 -0
- package/lib/http/errors/RateLimitError.d.ts +13 -0
- package/lib/http/errors/RateLimitError.d.ts.map +1 -0
- package/lib/http/errors/RateLimitError.js +16 -0
- package/lib/http/errors/RateLimitError.js.map +1 -0
- package/lib/http/errors/ServiceUnavailableError.d.ts +8 -0
- package/lib/http/errors/ServiceUnavailableError.d.ts.map +1 -0
- package/lib/http/errors/ServiceUnavailableError.js +10 -0
- package/lib/http/errors/ServiceUnavailableError.js.map +1 -0
- package/lib/http/errors/ValidationError.d.ts +9 -0
- package/lib/http/errors/ValidationError.d.ts.map +1 -0
- package/lib/http/errors/ValidationError.js +12 -0
- package/lib/http/errors/ValidationError.js.map +1 -0
- package/lib/http/errors/index.d.ts +11 -0
- package/lib/http/errors/index.d.ts.map +1 -0
- package/lib/http/errors/index.js +12 -0
- package/lib/http/errors/index.js.map +1 -0
- package/lib/http/middleware/apiKey.d.ts +9 -0
- package/lib/http/middleware/apiKey.d.ts.map +1 -0
- package/lib/http/middleware/apiKey.js +71 -0
- package/lib/http/middleware/apiKey.js.map +1 -0
- package/lib/http/middleware/csrf.d.ts +63 -0
- package/lib/http/middleware/csrf.d.ts.map +1 -0
- package/lib/http/middleware/csrf.js +169 -0
- package/lib/http/middleware/csrf.js.map +1 -0
- package/lib/http/middleware/httpLogger.d.ts +39 -0
- package/lib/http/middleware/httpLogger.d.ts.map +1 -0
- package/lib/http/middleware/httpLogger.js +118 -0
- package/lib/http/middleware/httpLogger.js.map +1 -0
- package/lib/http/middleware/idempotency.d.ts +48 -0
- package/lib/http/middleware/idempotency.d.ts.map +1 -0
- package/lib/http/middleware/idempotency.js +180 -0
- package/lib/http/middleware/idempotency.js.map +1 -0
- package/lib/http/middleware/rateLimit.d.ts +105 -0
- package/lib/http/middleware/rateLimit.d.ts.map +1 -0
- package/lib/http/middleware/rateLimit.js +84 -0
- package/lib/http/middleware/rateLimit.js.map +1 -0
- package/lib/http/middleware/requireAuth.d.ts +58 -0
- package/lib/http/middleware/requireAuth.d.ts.map +1 -0
- package/lib/http/middleware/requireAuth.js +63 -0
- package/lib/http/middleware/requireAuth.js.map +1 -0
- package/lib/http/middleware/requirePermission.d.ts +23 -0
- package/lib/http/middleware/requirePermission.d.ts.map +1 -0
- package/lib/http/middleware/requirePermission.js +50 -0
- package/lib/http/middleware/requirePermission.js.map +1 -0
- package/lib/http/middleware/resolveTenant.d.ts +41 -0
- package/lib/http/middleware/resolveTenant.d.ts.map +1 -0
- package/lib/http/middleware/resolveTenant.js +17 -0
- package/lib/http/middleware/resolveTenant.js.map +1 -0
- package/lib/http/streaming/sse.d.ts +31 -0
- package/lib/http/streaming/sse.d.ts.map +1 -0
- package/lib/http/streaming/sse.js +11 -0
- package/lib/http/streaming/sse.js.map +1 -0
- package/lib/http/streaming/streamLLM.d.ts +94 -0
- package/lib/http/streaming/streamLLM.d.ts.map +1 -0
- package/lib/http/streaming/streamLLM.js +94 -0
- package/lib/http/streaming/streamLLM.js.map +1 -0
- package/lib/http/utils/authCookies.d.ts +74 -0
- package/lib/http/utils/authCookies.d.ts.map +1 -0
- package/lib/http/utils/authCookies.js +102 -0
- package/lib/http/utils/authCookies.js.map +1 -0
- package/lib/http/utils/clientIp.d.ts +85 -0
- package/lib/http/utils/clientIp.d.ts.map +1 -0
- package/lib/http/utils/clientIp.js +249 -0
- package/lib/http/utils/clientIp.js.map +1 -0
- package/lib/http/utils/index.d.ts +4 -0
- package/lib/http/utils/index.d.ts.map +1 -0
- package/lib/http/utils/index.js +5 -0
- package/lib/http/utils/index.js.map +1 -0
- package/lib/http/utils/metaTags.d.ts +49 -0
- package/lib/http/utils/metaTags.d.ts.map +1 -0
- package/lib/http/utils/metaTags.js +32 -0
- package/lib/http/utils/metaTags.js.map +1 -0
- package/lib/http/utils/publicSuffix.d.ts +34 -0
- package/lib/http/utils/publicSuffix.d.ts.map +1 -0
- package/lib/http/utils/publicSuffix.js +276 -0
- package/lib/http/utils/publicSuffix.js.map +1 -0
- package/lib/http/utils/uploads.d.ts +92 -0
- package/lib/http/utils/uploads.d.ts.map +1 -0
- package/lib/http/utils/uploads.js +126 -0
- package/lib/http/utils/uploads.js.map +1 -0
- package/lib/http/utils/validate.d.ts +41 -0
- package/lib/http/utils/validate.d.ts.map +1 -0
- package/lib/http/utils/validate.js +55 -0
- package/lib/http/utils/validate.js.map +1 -0
- package/lib/http/utils/webhooks.d.ts +63 -0
- package/lib/http/utils/webhooks.d.ts.map +1 -0
- package/lib/http/utils/webhooks.js +133 -0
- package/lib/http/utils/webhooks.js.map +1 -0
- package/lib/http/ws/auth.d.ts +46 -0
- package/lib/http/ws/auth.d.ts.map +1 -0
- package/lib/http/ws/auth.js +123 -0
- package/lib/http/ws/auth.js.map +1 -0
- package/lib/index.d.ts +80 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +61 -0
- package/lib/index.js.map +1 -0
- package/lib/kernel/index.d.ts +3 -0
- package/lib/kernel/index.d.ts.map +1 -0
- package/lib/kernel/index.js +3 -0
- package/lib/kernel/index.js.map +1 -0
- package/lib/libraries/.gitkeep +0 -0
- package/lib/libraries/ai/CHANGELOG.md +17 -0
- package/lib/libraries/ai/README.md +164 -0
- package/lib/libraries/ai/adapters/AnthropicAdapter.ts +382 -0
- package/lib/libraries/ai/adapters/LLMProvider.ts +76 -0
- package/lib/libraries/ai/adapters/OpenAIAdapter.ts +466 -0
- package/lib/libraries/ai/experimental/index.ts +20 -0
- package/lib/libraries/ai/index.ts +128 -0
- package/lib/libraries/ai/library.json +19 -0
- package/lib/libraries/ai/loop/agentLoop.ts +377 -0
- package/lib/libraries/ai/prompts/definePrompt.ts +0 -0
- package/lib/libraries/ai/rag/retrieveAndAnswer.ts +177 -0
- package/lib/libraries/ai/streaming/streamLLM.ts +94 -0
- package/lib/libraries/ai/structured/completeStructured.ts +143 -0
- package/lib/libraries/ai/tokens/Tokenizer.ts +216 -0
- package/lib/libraries/ai/tools/defineTool.ts +208 -0
- package/lib/libraries/ai/types.ts +260 -0
- package/lib/libraries/chunking/ChunkingService.ts +103 -0
- package/lib/libraries/chunking/README.md +104 -0
- package/lib/libraries/chunking/docs/api-reference.md +549 -0
- package/lib/libraries/chunking/docs/best-practices.md +321 -0
- package/lib/libraries/chunking/docs/code-organization.md +538 -0
- package/lib/libraries/chunking/docs/configuration.md +418 -0
- package/lib/libraries/chunking/docs/index.md +236 -0
- package/lib/libraries/chunking/docs/quick-start.md +298 -0
- package/lib/libraries/chunking/docs/strategies.md +407 -0
- package/lib/libraries/chunking/docs/summary.md +258 -0
- package/lib/libraries/chunking/docs/troubleshooting.md +527 -0
- package/lib/libraries/chunking/index.ts +17 -0
- package/lib/libraries/chunking/library.json +16 -0
- package/lib/libraries/chunking/strategies/ChunkingStrategy.ts +13 -0
- package/lib/libraries/chunking/strategies/FixedLengthChunkingStrategy.ts +88 -0
- package/lib/libraries/chunking/strategies/SemanticChunkingStrategy.ts +389 -0
- package/lib/libraries/chunking/strategies/SlidingWindowChunkingStrategy.ts +258 -0
- package/lib/libraries/chunking/types/index.ts +63 -0
- package/lib/libraries/email/EmailService.ts +591 -0
- package/lib/libraries/email/README.md +777 -0
- package/lib/libraries/email/TemplateRegistry.ts +148 -0
- package/lib/libraries/email/TemplateRenderer.ts +273 -0
- package/lib/libraries/email/index.ts +4 -0
- package/lib/libraries/email/initializeEmailService.ts +60 -0
- package/lib/libraries/email/library.json +12 -0
- package/lib/libraries/email/types/EmailAddress.ts +4 -0
- package/lib/libraries/email/types/EmailAttachment.ts +11 -0
- package/lib/libraries/email/types/EmailTag.ts +9 -0
- package/lib/libraries/email/types/EmailTemplate.ts +124 -0
- package/lib/libraries/email/types/SendBatchEmailsOptions.ts +9 -0
- package/lib/libraries/email/types/SendBatchEmailsResult.ts +9 -0
- package/lib/libraries/email/types/SendEmailOptions.ts +33 -0
- package/lib/libraries/email/types/SendEmailResult.ts +9 -0
- package/lib/libraries/email/types/index.ts +8 -0
- package/lib/libraries/weaviate/QueryBuilder.ts +292 -0
- package/lib/libraries/weaviate/README.md +284 -0
- package/lib/libraries/weaviate/Weaviate.ts +1419 -0
- package/lib/libraries/weaviate/WeaviateConfig.ts +268 -0
- package/lib/libraries/weaviate/docs/.gitkeep +1 -0
- package/lib/libraries/weaviate/docs/API_REFERENCE.md +1067 -0
- package/lib/libraries/weaviate/docs/CONFIGURATION.md +320 -0
- package/lib/libraries/weaviate/docs/ERROR_HANDLING.md +271 -0
- package/lib/libraries/weaviate/docs/MULTI_TENANCY.md +348 -0
- package/lib/libraries/weaviate/docs/PERFORMANCE.md +602 -0
- package/lib/libraries/weaviate/docs/PLUGIN_DEVELOPMENT.md +547 -0
- package/lib/libraries/weaviate/docs/QUICK_START.md +443 -0
- package/lib/libraries/weaviate/docs/README.md +269 -0
- package/lib/libraries/weaviate/docs/SCHEMA_GUIDE.md +630 -0
- package/lib/libraries/weaviate/docs/WEAVIATE_README.md +520 -0
- package/lib/libraries/weaviate/errors/WeaviateError.ts +92 -0
- package/lib/libraries/weaviate/errors/index.ts +1 -0
- package/lib/libraries/weaviate/index.ts +35 -0
- package/lib/libraries/weaviate/library.json +26 -0
- package/lib/libraries/weaviate/plugins/index.ts +2 -0
- package/lib/libraries/weaviate/schemas/SchemaRegistry.ts +284 -0
- package/lib/libraries/weaviate/schemas/index.ts +2 -0
- package/lib/libraries/weaviate/types/BM25SearchOptions.ts +9 -0
- package/lib/libraries/weaviate/types/ExtendedWeaviateClient.ts +7 -0
- package/lib/libraries/weaviate/types/HybridSearchOptions.ts +11 -0
- package/lib/libraries/weaviate/types/MultiTenancy.ts +81 -0
- package/lib/libraries/weaviate/types/Plugin.ts +17 -0
- package/lib/libraries/weaviate/types/SchemaConfig.ts +25 -0
- package/lib/libraries/weaviate/types/SearchMethod.ts +8 -0
- package/lib/libraries/weaviate/types/SearchOptions.ts +16 -0
- package/lib/libraries/weaviate/types/SearchRequest.ts +19 -0
- package/lib/libraries/weaviate/types/SearchResult.ts +16 -0
- package/lib/libraries/weaviate/types/SearchableField.ts +87 -0
- package/lib/libraries/weaviate/types/VectorIndexConfig.ts +19 -0
- package/lib/libraries/weaviate/types/VectorSearchOptions.ts +18 -0
- package/lib/libraries/weaviate/types/VectorizerConfig.ts +8 -0
- package/lib/libraries/weaviate/types/index.ts +29 -0
- package/lib/libraries/weaviate/utils/TenantContextManager.ts +94 -0
- package/lib/modules/accounts/index.ts +47 -0
- package/lib/modules/accounts/module.json +15 -0
- package/lib/modules/accounts/permissions.ts +33 -0
- package/lib/modules/accounts/routes.ts +200 -0
- package/lib/modules/accounts/schema.ts +219 -0
- package/lib/modules/accounts/services/AccountService.ts +44 -0
- package/lib/modules/accounts/validation/schemas.ts +70 -0
- package/lib/modules/oauth/adapters/GmailOAuthAdapter.ts +35 -0
- package/lib/modules/oauth/adapters/GoogleOAuthAdapter.ts +278 -0
- package/lib/modules/oauth/adapters/MicrosoftOAuthAdapter.ts +269 -0
- package/lib/modules/oauth/adapters/MockOAuthAdapter.ts +138 -0
- package/lib/modules/oauth/adapters/OAuthAdapter.ts +211 -0
- package/lib/modules/oauth/adapters/OAuthAdapterRegistry.ts +77 -0
- package/lib/modules/oauth/adapters/OutlookOAuthAdapter.ts +38 -0
- package/lib/modules/oauth/index.ts +79 -0
- package/lib/modules/oauth/module.json +23 -0
- package/lib/modules/oauth/permissions.ts +39 -0
- package/lib/modules/oauth/routes.ts +497 -0
- package/lib/modules/oauth/schema.ts +127 -0
- package/lib/modules/oauth/services/OAuthConnectionService.ts +147 -0
- package/lib/modules/oauth/state.ts +234 -0
- package/lib/modules/oauth/stateJtiCache.ts +85 -0
- package/lib/modules/oauth/verifyIdToken.ts +178 -0
- package/lib/modules/outbox/EventEmitter.ts +106 -0
- package/lib/modules/outbox/OutboxDrainer.ts +163 -0
- package/lib/modules/outbox/handlers/EventHandler.ts +115 -0
- package/lib/modules/outbox/index.ts +43 -0
- package/lib/modules/outbox/module.json +15 -0
- package/lib/modules/outbox/permissions.ts +36 -0
- package/lib/modules/outbox/routes.ts +219 -0
- package/lib/modules/outbox/schema.ts +207 -0
- package/lib/modules/outbox/services/OutboxEventService.ts +223 -0
- package/lib/observability/logger.d.ts +30 -0
- package/lib/observability/logger.d.ts.map +1 -0
- package/lib/observability/logger.js +110 -0
- package/lib/observability/logger.js.map +1 -0
- package/lib/observability/metrics.d.ts +3 -0
- package/lib/observability/metrics.d.ts.map +1 -0
- package/lib/observability/metrics.js +3 -0
- package/lib/observability/metrics.js.map +1 -0
- package/lib/observability/otel.d.ts +3 -0
- package/lib/observability/otel.d.ts.map +1 -0
- package/lib/observability/otel.js +3 -0
- package/lib/observability/otel.js.map +1 -0
- package/lib/observability/safeErrorFields.d.ts +14 -0
- package/lib/observability/safeErrorFields.d.ts.map +1 -0
- package/lib/observability/safeErrorFields.js +14 -0
- package/lib/observability/safeErrorFields.js.map +1 -0
- package/lib/observability/tracing.d.ts +3 -0
- package/lib/observability/tracing.d.ts.map +1 -0
- package/lib/observability/tracing.js +3 -0
- package/lib/observability/tracing.js.map +1 -0
- package/lib/package.json +4 -0
- package/lib/testing.d.ts +3 -0
- package/lib/testing.d.ts.map +1 -0
- package/lib/testing.js +3 -0
- package/lib/testing.js.map +1 -0
- package/package.json +193 -3
- package/templates/default/.claude/agents/qa-brief.md +106 -0
- package/templates/default/.claude/commands/sherpa-brief.md +23 -0
- package/templates/default/.cursor/rules/api.mdc +80 -0
- package/templates/default/.cursor/rules/commits.mdc +88 -0
- package/templates/default/.cursor/rules/security.mdc +92 -0
- package/templates/default/.cursor/rules/testing.mdc +123 -0
- package/templates/default/.cursor/rules/typescript.mdc +86 -0
- package/templates/default/.env.example +79 -0
- package/templates/default/.github/workflows/sherpa-brief.yml +180 -0
- package/templates/default/AGENTS.md +166 -0
- package/templates/default/CLAUDE.md +17 -0
- package/templates/default/README.md +97 -0
- package/templates/default/_gitignore +27 -0
- package/templates/default/docker-compose.yml +83 -0
- package/templates/default/drizzle.config.ts +34 -0
- package/templates/default/eslint.config.mjs +106 -0
- package/templates/default/package.json +57 -0
- package/templates/default/ship-api.config.ts +21 -0
- package/templates/default/src/client.ts +34 -0
- package/templates/default/src/config/modules.ts +23 -0
- package/templates/default/src/db/schema.ts +26 -0
- package/templates/default/src/environment.ts +81 -0
- package/templates/default/src/index.test.ts +53 -0
- package/templates/default/src/index.ts +11 -0
- package/templates/default/src/instrumentation.ts +13 -0
- package/templates/default/src/server.ts +90 -0
- package/templates/default/tsconfig.json +24 -0
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
# Weaviate - Generalized Vector Search Framework
|
|
2
|
+
|
|
3
|
+
A comprehensive, schema-driven framework for Weaviate vector database operations with support for hybrid search, plugins, and extensible architecture.
|
|
4
|
+
|
|
5
|
+
## 🚀 Key Features
|
|
6
|
+
|
|
7
|
+
- **Schema-Driven**: Define schemas in configuration files, not hardcoded methods
|
|
8
|
+
- **Generic Operations**: Single methods work with any schema
|
|
9
|
+
- **Hybrid Search**: Vector + BM25 search with configurable alpha parameter
|
|
10
|
+
- **Query Builder**: Fluent API for complex queries
|
|
11
|
+
- **Plugin System**: Extensible with custom plugins for data enrichment
|
|
12
|
+
- **Smart Search**: Automatic method selection based on query characteristics
|
|
13
|
+
- **Universal Search**: Search across multiple schemas simultaneously
|
|
14
|
+
- **Multi-Tenancy**: Built-in tenant isolation and management
|
|
15
|
+
- **Tenant-Aware Operations**: All search methods support tenant context
|
|
16
|
+
- **Type Safety**: Full TypeScript support with proper interfaces
|
|
17
|
+
|
|
18
|
+
## 🏗️ Architecture
|
|
19
|
+
|
|
20
|
+
### Core Components
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Weaviate Framework
|
|
24
|
+
├── Weaviate # Main class with all vector database operations
|
|
25
|
+
├── WeaviateConfig # Configuration and connection management
|
|
26
|
+
├── SchemaRegistry # Schema management and validation
|
|
27
|
+
├── QueryBuilder # Fluent query building API
|
|
28
|
+
├── Plugin System # Extensible plugin architecture
|
|
29
|
+
└── Schema Configurations # Injected schema definitions
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Constructor & Initialization
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// Constructor - initializes from WeaviateConfigService
|
|
36
|
+
new Weaviate() // Simple constructor
|
|
37
|
+
|
|
38
|
+
// Initialize with schemas during app startup
|
|
39
|
+
await weaviate.initializeSchemas(schemas) // Initialize with schemas
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Schema Organization
|
|
43
|
+
|
|
44
|
+
Schemas are now organized in a clean separation between application configuration and framework code:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
src/
|
|
48
|
+
├── config/schemas/ # Application-specific schemas
|
|
49
|
+
│ ├── Person.ts # Individual schema files
|
|
50
|
+
│ ├── Organization.ts
|
|
51
|
+
│ ├── Account.ts
|
|
52
|
+
│ └── index.ts # Schema exports
|
|
53
|
+
└── lib/weaviate/
|
|
54
|
+
├── schemas/ # Framework schema management
|
|
55
|
+
│ ├── SchemaRegistry.ts
|
|
56
|
+
│ └── index.ts # Re-exports from config
|
|
57
|
+
└── types/ # Framework types
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Schema Configuration
|
|
61
|
+
|
|
62
|
+
Schemas are defined in individual files with rich metadata:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
{
|
|
66
|
+
name: "Person",
|
|
67
|
+
description: "A person in the social graph",
|
|
68
|
+
vectorizer: {
|
|
69
|
+
name: "text2vec-cohere",
|
|
70
|
+
model: "embed-multilingual-v3.0",
|
|
71
|
+
dimensions: 1024,
|
|
72
|
+
},
|
|
73
|
+
properties: [
|
|
74
|
+
{
|
|
75
|
+
name: "fullName",
|
|
76
|
+
dataType: ["string"],
|
|
77
|
+
indexSearchable: true,
|
|
78
|
+
weight: 2.0,
|
|
79
|
+
boost: 1.5,
|
|
80
|
+
},
|
|
81
|
+
// ... more properties
|
|
82
|
+
],
|
|
83
|
+
searchableFields: ["fullName", "headline", "bio"],
|
|
84
|
+
filterableFields: ["city", "countryCode"],
|
|
85
|
+
plugins: ["personEnrichment", "similarityBoost"],
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 📖 Usage
|
|
90
|
+
|
|
91
|
+
### Basic Initialization
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import Weaviate from "../Weaviate.js";
|
|
95
|
+
import { WeaviateConfigService } from "../WeaviateConfig.js";
|
|
96
|
+
import { schemas } from "../../../config/schemas/index.js";
|
|
97
|
+
|
|
98
|
+
// Initialize Weaviate client first
|
|
99
|
+
await WeaviateConfigService.initializeClient();
|
|
100
|
+
|
|
101
|
+
// Create Weaviate instance (handles everything internally!)
|
|
102
|
+
const weaviate = new Weaviate();
|
|
103
|
+
|
|
104
|
+
// Initialize schemas (only required during app startup)
|
|
105
|
+
await weaviate.initializeSchemas(schemas);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Generic Search
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// Search any schema with discriminated union pattern
|
|
112
|
+
const results = await weaviate.search("Person", {
|
|
113
|
+
method: "hybrid",
|
|
114
|
+
options: {
|
|
115
|
+
hybrid: {
|
|
116
|
+
query: "software engineer",
|
|
117
|
+
alpha: 0.5,
|
|
118
|
+
},
|
|
119
|
+
limit: 10,
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Smart search with automatic method selection
|
|
124
|
+
const smartResults = await weaviate.smartSearch("Person", "machine learning expert");
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Query Builder
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
// Fluent query building
|
|
131
|
+
const query = weaviate
|
|
132
|
+
.queryBuilder("Person")
|
|
133
|
+
.limit(10)
|
|
134
|
+
.whereField("city", "Equal", "San Francisco")
|
|
135
|
+
.sort("createdAt", "desc")
|
|
136
|
+
.includeVector();
|
|
137
|
+
|
|
138
|
+
// Build different search types
|
|
139
|
+
const vectorOptions = query.buildVectorSearch("engineer", { certainty: 0.8 });
|
|
140
|
+
const hybridOptions = query.buildHybridSearch("data scientist", { alpha: 0.6 });
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Query Patterns
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { QueryPatterns } from "../QueryBuilder.js";
|
|
147
|
+
|
|
148
|
+
// Date range search
|
|
149
|
+
const dateQuery = QueryPatterns.dateRange("createdAt", startDate, endDate);
|
|
150
|
+
|
|
151
|
+
// Text contains search
|
|
152
|
+
const textQuery = QueryPatterns.textContains("headline", "senior");
|
|
153
|
+
|
|
154
|
+
// Multiple values search
|
|
155
|
+
const multiQuery = QueryPatterns.inValues("city", ["SF", "NYC", "Seattle"]);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Universal Search
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// Search across multiple schemas
|
|
162
|
+
const allResults = await framework.searchAll(["Person", "Organization", "Conversation"], "hybrid", {
|
|
163
|
+
hybrid: { query: "artificial intelligence", alpha: 0.6 },
|
|
164
|
+
limit: 5,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
console.log(`People: ${allResults.Person.objects.length}`);
|
|
168
|
+
console.log(`Organizations: ${allResults.Organization.objects.length}`);
|
|
169
|
+
console.log(`Conversations: ${allResults.Conversation.objects.length}`);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## 🏢 Multi-Tenancy
|
|
173
|
+
|
|
174
|
+
### Multi-Tenant Schema Configuration
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
const UserDocuments: SchemaConfig = {
|
|
178
|
+
name: "UserDocuments",
|
|
179
|
+
description: "User documents with multi-tenancy",
|
|
180
|
+
vectorizer: "text2vec-openai",
|
|
181
|
+
multiTenancy: {
|
|
182
|
+
enabled: true,
|
|
183
|
+
autoTenantCreation: true,
|
|
184
|
+
autoTenantActivation: true,
|
|
185
|
+
},
|
|
186
|
+
properties: [
|
|
187
|
+
{
|
|
188
|
+
name: "title",
|
|
189
|
+
type: "string",
|
|
190
|
+
searchable: true,
|
|
191
|
+
filterable: true,
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "content",
|
|
195
|
+
type: "text",
|
|
196
|
+
searchable: true,
|
|
197
|
+
vectorizable: true,
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
};
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Tenant Management
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// Create tenants for different organizations
|
|
207
|
+
await weaviate.createTenant("UserDocuments", { name: "acme-corp" });
|
|
208
|
+
await weaviate.createTenant("UserDocuments", { name: "beta-llc" });
|
|
209
|
+
|
|
210
|
+
// List all tenants
|
|
211
|
+
const tenants = await weaviate.listTenants("UserDocuments");
|
|
212
|
+
|
|
213
|
+
// Update tenant activity status
|
|
214
|
+
await weaviate.updateTenant("UserDocuments", "acme-corp", {
|
|
215
|
+
activityStatus: "COLD", // Move to cold storage
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// Get tenant statistics
|
|
219
|
+
const stats = await weaviate.getTenantStats("UserDocuments");
|
|
220
|
+
console.log(`Total tenants: ${stats.totalTenants}`);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Tenant-Aware Operations
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
// Search within a specific tenant
|
|
227
|
+
const results = await weaviate.searchWithTenant(
|
|
228
|
+
"UserDocuments",
|
|
229
|
+
"hybrid",
|
|
230
|
+
{
|
|
231
|
+
hybrid: { query: "machine learning", alpha: 0.5 },
|
|
232
|
+
},
|
|
233
|
+
"acme-corp",
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
// Smart search with tenant context
|
|
237
|
+
const smartResults = await weaviate.smartSearchWithTenant(
|
|
238
|
+
"UserDocuments",
|
|
239
|
+
"AI expert",
|
|
240
|
+
"acme-corp",
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
// Using tenant context manager
|
|
244
|
+
import TenantContextManager from "./utils/TenantContextManager.js";
|
|
245
|
+
|
|
246
|
+
await TenantContextManager.withContext("acme-corp", "HOT", async () => {
|
|
247
|
+
const results = await weaviate.smartSearch("UserDocuments", "search query");
|
|
248
|
+
// All operations automatically use the tenant context
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## 🔌 Plugin System
|
|
253
|
+
|
|
254
|
+
### Built-in Plugins
|
|
255
|
+
|
|
256
|
+
No default plugins are included. You can create and register custom plugins as needed.
|
|
257
|
+
|
|
258
|
+
### Custom Plugin Example
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
class CustomEnrichmentPlugin implements Plugin {
|
|
262
|
+
name = "customEnrichment";
|
|
263
|
+
version = "1.0.0";
|
|
264
|
+
description = "Custom data enrichment";
|
|
265
|
+
|
|
266
|
+
hooks = {
|
|
267
|
+
beforeSearch: (className, options) => {
|
|
268
|
+
// Enhance search options
|
|
269
|
+
return options;
|
|
270
|
+
},
|
|
271
|
+
afterSearch: (className, result) => {
|
|
272
|
+
// Enhance search results
|
|
273
|
+
return result;
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Register custom plugin
|
|
279
|
+
framework.registerPlugin(new CustomEnrichmentPlugin());
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## 🎯 Search Methods
|
|
283
|
+
|
|
284
|
+
### Vector Search (Semantic)
|
|
285
|
+
|
|
286
|
+
- **Best for**: Natural language queries, concept-based search
|
|
287
|
+
- **Use cases**: "Find people interested in machine learning"
|
|
288
|
+
- **Strengths**: Understands context and meaning
|
|
289
|
+
|
|
290
|
+
### BM25 Search (Keyword)
|
|
291
|
+
|
|
292
|
+
- **Best for**: Exact keyword matching, specific terms
|
|
293
|
+
- **Use cases**: "Find people with 'Python' in their bio"
|
|
294
|
+
- **Strengths**: Fast, precise keyword matching
|
|
295
|
+
|
|
296
|
+
### Hybrid Search (Vector + BM25)
|
|
297
|
+
|
|
298
|
+
- **Best for**: Most use cases - combines both methods
|
|
299
|
+
- **Alpha parameter**:
|
|
300
|
+
- `0.0` = Pure BM25 (keyword-only)
|
|
301
|
+
- `0.5` = Balanced (default)
|
|
302
|
+
- `1.0` = Pure vector (semantic-only)
|
|
303
|
+
|
|
304
|
+
## 📊 Performance Characteristics
|
|
305
|
+
|
|
306
|
+
| Method | Speed | Accuracy | Best For |
|
|
307
|
+
| ------ | ------ | --------------- | ------------------------ |
|
|
308
|
+
| Vector | Medium | High (semantic) | Natural language queries |
|
|
309
|
+
| BM25 | Fast | High (keyword) | Exact term matching |
|
|
310
|
+
| Hybrid | Medium | **Highest** | General purpose search |
|
|
311
|
+
|
|
312
|
+
## 🔧 Advanced Features
|
|
313
|
+
|
|
314
|
+
### Schema Registry
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
// Get schema information
|
|
318
|
+
const personInfo = framework.getSchemaInfo("Person");
|
|
319
|
+
console.log("Searchable fields:", personInfo.searchableFields);
|
|
320
|
+
console.log(
|
|
321
|
+
"Plugins:",
|
|
322
|
+
personInfo.plugins.map((p) => p.name),
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
// Get framework statistics
|
|
326
|
+
const stats = framework.getStats();
|
|
327
|
+
console.log("Total schemas:", stats.registry.totalSchemas);
|
|
328
|
+
console.log("Schemas by category:", stats.registry.schemasByCategory);
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Custom Schema Registration
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
const customSchema = {
|
|
335
|
+
name: "Product",
|
|
336
|
+
description: "A product in the catalog",
|
|
337
|
+
vectorizer: { name: "text2vec-cohere" },
|
|
338
|
+
properties: [
|
|
339
|
+
{
|
|
340
|
+
name: "name",
|
|
341
|
+
dataType: ["string"],
|
|
342
|
+
indexSearchable: true,
|
|
343
|
+
weight: 2.0,
|
|
344
|
+
},
|
|
345
|
+
// ... more properties
|
|
346
|
+
],
|
|
347
|
+
searchableFields: ["name", "description"],
|
|
348
|
+
filterableFields: ["category", "price"],
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
framework.registerSchema(customSchema);
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Health Monitoring
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
// Health check
|
|
358
|
+
const isHealthy = await framework.healthCheck();
|
|
359
|
+
console.log(`Framework health: ${isHealthy ? "healthy" : "unhealthy"}`);
|
|
360
|
+
|
|
361
|
+
// Get service statistics
|
|
362
|
+
const stats = weaviate.getStats();
|
|
363
|
+
console.log("Service statistics:", stats);
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## 🚀 Architecture Benefits
|
|
367
|
+
|
|
368
|
+
### Unified API
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
// Simple, consistent interface for all schemas with discriminated union
|
|
372
|
+
const people = await weaviate.search("Person", {
|
|
373
|
+
method: "hybrid",
|
|
374
|
+
options: { hybrid: { query: "engineer", alpha: 0.5 } }
|
|
375
|
+
});
|
|
376
|
+
const orgs = await weaviate.search("Organization", {
|
|
377
|
+
method: "hybrid",
|
|
378
|
+
options: { hybrid: { query: "startup", alpha: 0.5 } }
|
|
379
|
+
});
|
|
380
|
+
const convs = await weaviate.search("Conversation", {
|
|
381
|
+
method: "hybrid",
|
|
382
|
+
options: { hybrid: { query: "AI", alpha: 0.5 } }
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// Or use convenience methods
|
|
386
|
+
const people = await weaviate.hybridSearch("Person", "engineer");
|
|
387
|
+
const orgs = await weaviate.smartSearch("Organization", "startup");
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## 📁 File Structure
|
|
391
|
+
|
|
392
|
+
```
|
|
393
|
+
src/
|
|
394
|
+
├── config/schemas/ # Application schemas
|
|
395
|
+
│ ├── Person.ts # Individual schema files
|
|
396
|
+
│ ├── Organization.ts
|
|
397
|
+
│ ├── Account.ts
|
|
398
|
+
│ ├── Conversation.ts
|
|
399
|
+
│ ├── Message.ts
|
|
400
|
+
│ └── index.ts # Schema exports
|
|
401
|
+
└── lib/weaviate/ # Framework code
|
|
402
|
+
├── Weaviate.ts # Main framework class with all operations
|
|
403
|
+
├── QueryBuilder.ts # Fluent query builder
|
|
404
|
+
├── WeaviateConfig.ts # Configuration and connection management
|
|
405
|
+
├── docs/ # Documentation
|
|
406
|
+
│ ├── README.md # Overview
|
|
407
|
+
│ ├── QUICK_START.md # Quick start guide
|
|
408
|
+
│ └── WEAVIATE_README.md # Comprehensive docs
|
|
409
|
+
├── schemas/ # Framework schema management
|
|
410
|
+
│ ├── SchemaRegistry.ts # Schema registry
|
|
411
|
+
│ └── index.ts # Re-exports from config
|
|
412
|
+
├── types/ # TypeScript definitions
|
|
413
|
+
│ ├── SchemaConfig.ts
|
|
414
|
+
│ ├── SearchOptions.ts
|
|
415
|
+
│ └── index.ts
|
|
416
|
+
├── plugins/ # Plugin system
|
|
417
|
+
│ └── index.ts # Custom plugins can be added here
|
|
418
|
+
└── Weaviate.example.ts # Usage examples
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
## 🧪 Testing with Dependency Injection
|
|
422
|
+
|
|
423
|
+
The new constructor makes testing much easier with dependency injection:
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
import { Weaviate } from "./Weaviate.js";
|
|
427
|
+
import { SchemaConfig } from "./types/index.js";
|
|
428
|
+
|
|
429
|
+
// Mock schemas for testing
|
|
430
|
+
const mockSchemas: Record<string, SchemaConfig> = {
|
|
431
|
+
Person: {
|
|
432
|
+
name: "Person",
|
|
433
|
+
description: "Test person schema",
|
|
434
|
+
vectorizer: { name: "text2vec-cohere", model: "embed-multilingual-v3.0", dimensions: 1024 },
|
|
435
|
+
vectorIndexConfig: { distance: "cosine", ef: 64, efConstruction: 128, maxConnections: 16 },
|
|
436
|
+
properties: [],
|
|
437
|
+
searchableFields: [],
|
|
438
|
+
filterableFields: [],
|
|
439
|
+
sortableFields: [],
|
|
440
|
+
plugins: [],
|
|
441
|
+
metadata: { category: "entity", priority: "high", searchWeight: 1.0 },
|
|
442
|
+
},
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
// Test with mock dependencies
|
|
446
|
+
// Mock WeaviateConfigService to return your mock client
|
|
447
|
+
vi.mock("./WeaviateConfig.js", () => ({
|
|
448
|
+
WeaviateConfigService: {
|
|
449
|
+
getClient: vi.fn().mockReturnValue(mockClient),
|
|
450
|
+
},
|
|
451
|
+
}));
|
|
452
|
+
|
|
453
|
+
const weaviate = new Weaviate();
|
|
454
|
+
// Register test schemas
|
|
455
|
+
weaviate.registerSchema(mockSchemas.Person);
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Testing Benefits:
|
|
459
|
+
|
|
460
|
+
- **Simplified Mocking**: Mock just the WeaviateConfigService
|
|
461
|
+
- **Isolation**: Test with mock schemas and dependencies
|
|
462
|
+
- **Flexibility**: Use different schemas for different test scenarios
|
|
463
|
+
- **Reliability**: No external dependencies in tests
|
|
464
|
+
- **Speed**: Fast unit tests without database connections
|
|
465
|
+
|
|
466
|
+
## 🎨 Benefits of the New Framework
|
|
467
|
+
|
|
468
|
+
### 1. **Extensibility**
|
|
469
|
+
|
|
470
|
+
- Add new schemas without code changes
|
|
471
|
+
- Register custom plugins for any schema
|
|
472
|
+
- Extend functionality without modifying core code
|
|
473
|
+
|
|
474
|
+
### 2. **Maintainability**
|
|
475
|
+
|
|
476
|
+
- Schema definitions in external files
|
|
477
|
+
- Generic methods reduce code duplication
|
|
478
|
+
- Plugin system for modular functionality
|
|
479
|
+
|
|
480
|
+
### 3. **Flexibility**
|
|
481
|
+
|
|
482
|
+
- Query builder for complex queries
|
|
483
|
+
- Smart search with automatic method selection
|
|
484
|
+
- Universal search across multiple schemas
|
|
485
|
+
|
|
486
|
+
### 4. **Performance**
|
|
487
|
+
|
|
488
|
+
- Optimized search methods
|
|
489
|
+
- Plugin hooks for data enrichment
|
|
490
|
+
- Configurable search parameters
|
|
491
|
+
|
|
492
|
+
### 5. **Developer Experience**
|
|
493
|
+
|
|
494
|
+
- Fluent API for query building
|
|
495
|
+
- Type safety with TypeScript
|
|
496
|
+
- Comprehensive examples and documentation
|
|
497
|
+
|
|
498
|
+
## 🔮 Future Enhancements
|
|
499
|
+
|
|
500
|
+
- **GraphQL Integration**: Direct GraphQL query support
|
|
501
|
+
- **Real-time Updates**: WebSocket support for live data
|
|
502
|
+
- **Advanced Analytics**: Built-in analytics and insights
|
|
503
|
+
- **Multi-tenant Support**: Schema isolation for multiple tenants
|
|
504
|
+
- **Caching Layer**: Intelligent caching for improved performance
|
|
505
|
+
- **A/B Testing**: Built-in A/B testing for search algorithms
|
|
506
|
+
|
|
507
|
+
## 📚 Examples
|
|
508
|
+
|
|
509
|
+
See `../Weaviate.example.ts` for comprehensive usage examples including:
|
|
510
|
+
|
|
511
|
+
- Generic search patterns
|
|
512
|
+
- Smart search with automatic method selection
|
|
513
|
+
- Query builder usage
|
|
514
|
+
- Query patterns for common operations
|
|
515
|
+
- Universal search across multiple schemas
|
|
516
|
+
- Custom schema registration
|
|
517
|
+
- Plugin system usage
|
|
518
|
+
- Complete workflow examples
|
|
519
|
+
|
|
520
|
+
The Weaviate provides a powerful, flexible, and extensible foundation for vector search operations in your social-sweep API! 🚀
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes for Weaviate operations
|
|
3
|
+
*/
|
|
4
|
+
export enum WeaviateErrorCode {
|
|
5
|
+
// Schema errors
|
|
6
|
+
SCHEMA_VALIDATION_ERROR = "SCHEMA_VALIDATION_ERROR",
|
|
7
|
+
SCHEMA_CREATION_ERROR = "SCHEMA_CREATION_ERROR",
|
|
8
|
+
SCHEMA_NOT_FOUND = "SCHEMA_NOT_FOUND",
|
|
9
|
+
|
|
10
|
+
// Search errors
|
|
11
|
+
SEARCH_ERROR = "SEARCH_ERROR",
|
|
12
|
+
INVALID_SEARCH_METHOD = "INVALID_SEARCH_METHOD",
|
|
13
|
+
|
|
14
|
+
// CRUD errors
|
|
15
|
+
OBJECT_CREATION_ERROR = "OBJECT_CREATION_ERROR",
|
|
16
|
+
OBJECT_UPDATE_ERROR = "OBJECT_UPDATE_ERROR",
|
|
17
|
+
OBJECT_DELETE_ERROR = "OBJECT_DELETE_ERROR",
|
|
18
|
+
OBJECT_RETRIEVAL_ERROR = "OBJECT_RETRIEVAL_ERROR",
|
|
19
|
+
BATCH_OPERATION_ERROR = "BATCH_OPERATION_ERROR",
|
|
20
|
+
|
|
21
|
+
// Tenant errors
|
|
22
|
+
TENANT_CREATION_ERROR = "TENANT_CREATION_ERROR",
|
|
23
|
+
TENANT_UPDATE_ERROR = "TENANT_UPDATE_ERROR",
|
|
24
|
+
TENANT_DELETE_ERROR = "TENANT_DELETE_ERROR",
|
|
25
|
+
TENANT_RETRIEVAL_ERROR = "TENANT_RETRIEVAL_ERROR",
|
|
26
|
+
TENANT_VALIDATION_ERROR = "TENANT_VALIDATION_ERROR",
|
|
27
|
+
TENANT_NOT_FOUND = "TENANT_NOT_FOUND",
|
|
28
|
+
|
|
29
|
+
// General errors
|
|
30
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
|
31
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
32
|
+
CONNECTION_ERROR = "CONNECTION_ERROR",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Custom error class for Weaviate operations
|
|
37
|
+
* Provides structured error information with error codes and additional details
|
|
38
|
+
*/
|
|
39
|
+
export class WeaviateError extends Error {
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new WeaviateError
|
|
42
|
+
* @param message - Human-readable error message
|
|
43
|
+
* @param code - Error code for programmatic handling
|
|
44
|
+
* @param details - Additional error details or the original error
|
|
45
|
+
*/
|
|
46
|
+
constructor(
|
|
47
|
+
message: string,
|
|
48
|
+
public readonly code: WeaviateErrorCode,
|
|
49
|
+
public readonly details?: any,
|
|
50
|
+
) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.name = "WeaviateError";
|
|
53
|
+
|
|
54
|
+
// Maintain proper stack trace for debugging
|
|
55
|
+
if (Error.captureStackTrace) {
|
|
56
|
+
Error.captureStackTrace(this, WeaviateError);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Check if the error is a specific type
|
|
62
|
+
*/
|
|
63
|
+
is(code: WeaviateErrorCode): boolean {
|
|
64
|
+
return this.code === code;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get a JSON representation of the error
|
|
69
|
+
*/
|
|
70
|
+
toJSON() {
|
|
71
|
+
return {
|
|
72
|
+
name: this.name,
|
|
73
|
+
message: this.message,
|
|
74
|
+
code: this.code,
|
|
75
|
+
details: this.details,
|
|
76
|
+
stack: this.stack,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Create a WeaviateError from an unknown error
|
|
82
|
+
*/
|
|
83
|
+
static from(error: unknown, code: WeaviateErrorCode, message?: string): WeaviateError {
|
|
84
|
+
if (error instanceof WeaviateError) {
|
|
85
|
+
return error;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const errorMessage = message || (error instanceof Error ? error.message : String(error));
|
|
89
|
+
|
|
90
|
+
return new WeaviateError(errorMessage, code, error);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WeaviateError, WeaviateErrorCode } from "./WeaviateError.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Main Weaviate framework exports
|
|
2
|
+
|
|
3
|
+
// Errors
|
|
4
|
+
export { WeaviateError, WeaviateErrorCode } from "./errors/index.js";
|
|
5
|
+
// Query builder and utilities
|
|
6
|
+
export { createQueryBuilder, QueryBuilder, QueryPatterns } from "./QueryBuilder.js";
|
|
7
|
+
// Schema system
|
|
8
|
+
export { default as SchemaRegistry } from "./schemas/SchemaRegistry.js";
|
|
9
|
+
// Types
|
|
10
|
+
export type {
|
|
11
|
+
BM25SearchOptions,
|
|
12
|
+
CreateTenantOptions,
|
|
13
|
+
HybridSearchOptions,
|
|
14
|
+
MultiTenancyConfig,
|
|
15
|
+
Plugin,
|
|
16
|
+
SchemaConfig,
|
|
17
|
+
SearchableField,
|
|
18
|
+
SearchMethod,
|
|
19
|
+
SearchOptions,
|
|
20
|
+
SearchRequest,
|
|
21
|
+
SearchResult,
|
|
22
|
+
Tenant,
|
|
23
|
+
TenantActivityStatus,
|
|
24
|
+
TenantContext,
|
|
25
|
+
TenantManagementResult,
|
|
26
|
+
TenantStats,
|
|
27
|
+
UpdateTenantOptions,
|
|
28
|
+
VectorIndexConfig,
|
|
29
|
+
Vectorizer,
|
|
30
|
+
VectorizerConfig,
|
|
31
|
+
VectorSearchOptions,
|
|
32
|
+
} from "./types/index.js";
|
|
33
|
+
export type { WeaviateOptions } from "./Weaviate.js";
|
|
34
|
+
export { default as Weaviate } from "./Weaviate.js";
|
|
35
|
+
export { WeaviateConfigService } from "./WeaviateConfig.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "weaviate",
|
|
3
|
+
"description": "Vector database framework with hybrid search, plugins, and multi-tenancy support",
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"dependencies": [],
|
|
6
|
+
"npmDependencies": {
|
|
7
|
+
"weaviate-client": "^3.0.0"
|
|
8
|
+
},
|
|
9
|
+
"requiredEnvVars": [],
|
|
10
|
+
"optionalEnvVars": [
|
|
11
|
+
"WEAVIATE_HOST",
|
|
12
|
+
"WEAVIATE_PORT",
|
|
13
|
+
"WEAVIATE_SCHEME",
|
|
14
|
+
"WEAVIATE_API_KEY",
|
|
15
|
+
"WEAVIATE_HEADERS",
|
|
16
|
+
"WEAVIATE_MULTI_TENANCY_ENABLED",
|
|
17
|
+
"WEAVIATE_AUTO_TENANT_CREATION",
|
|
18
|
+
"WEAVIATE_AUTO_TENANT_ACTIVATION",
|
|
19
|
+
"WEAVIATE_SKIP_INIT_CHECKS"
|
|
20
|
+
],
|
|
21
|
+
"postInstall": [
|
|
22
|
+
"Configure WEAVIATE_HOST in .env (defaults to localhost)",
|
|
23
|
+
"Set WEAVIATE_API_KEY for authentication (required for cloud deployments)",
|
|
24
|
+
"Initialize schemas during app startup using weaviate.initializeSchemas()"
|
|
25
|
+
]
|
|
26
|
+
}
|