@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,320 @@
|
|
|
1
|
+
# Configuration Guide
|
|
2
|
+
|
|
3
|
+
This guide covers how to configure the Weaviate framework for your application.
|
|
4
|
+
|
|
5
|
+
## 🔧 Environment Variables
|
|
6
|
+
|
|
7
|
+
### Required Configuration
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Weaviate Connection
|
|
11
|
+
WEAVIATE_HOST=weaviate # Docker service name or localhost
|
|
12
|
+
WEAVIATE_PORT=8080 # Weaviate port
|
|
13
|
+
WEAVIATE_SCHEME=http # http or https
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Optional Configuration
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Authentication (if required)
|
|
20
|
+
WEAVIATE_API_KEY=your-api-key
|
|
21
|
+
|
|
22
|
+
# Custom Headers (JSON format)
|
|
23
|
+
WEAVIATE_HEADERS={"Authorization": "Bearer token"}
|
|
24
|
+
|
|
25
|
+
# Multi-Tenancy Configuration
|
|
26
|
+
WEAVIATE_MULTI_TENANCY_ENABLED=true
|
|
27
|
+
WEAVIATE_AUTO_TENANT_CREATION=true
|
|
28
|
+
WEAVIATE_AUTO_TENANT_ACTIVATION=true
|
|
29
|
+
|
|
30
|
+
# Environment Detection
|
|
31
|
+
NODE_ENV=development # Used for Docker detection
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 🐳 Docker Configuration
|
|
35
|
+
|
|
36
|
+
### Docker Compose Example
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
version: "3.8"
|
|
40
|
+
services:
|
|
41
|
+
weaviate:
|
|
42
|
+
container_name: social-sweep-weaviate
|
|
43
|
+
image: semitechnologies/weaviate:latest
|
|
44
|
+
restart: always
|
|
45
|
+
environment:
|
|
46
|
+
- QUERY_DEFAULTS_LIMIT=25
|
|
47
|
+
- AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true
|
|
48
|
+
- PERSISTENCE_DATA_PATH=/var/lib/weaviate
|
|
49
|
+
- DEFAULT_VECTORIZER_MODULE=none
|
|
50
|
+
- ENABLE_MODULES=text2vec-cohere,text2vec-huggingface,text2vec-palm,text2vec-openai,generative-openai,generative-cohere,generative-palm,ref2vec-centroid,reranker-cohere,qna-openai
|
|
51
|
+
- CLUSTER_HOSTNAME=node1
|
|
52
|
+
ports:
|
|
53
|
+
- "8080:8080"
|
|
54
|
+
volumes:
|
|
55
|
+
- weaviate_data_social-sweep:/var/lib/weaviate
|
|
56
|
+
|
|
57
|
+
api:
|
|
58
|
+
container_name: social-sweep-api
|
|
59
|
+
build: .
|
|
60
|
+
restart: always
|
|
61
|
+
env_file:
|
|
62
|
+
- .env
|
|
63
|
+
ports:
|
|
64
|
+
- "3000:3000"
|
|
65
|
+
depends_on:
|
|
66
|
+
- weaviate
|
|
67
|
+
volumes:
|
|
68
|
+
- ./:/usr/src/app
|
|
69
|
+
- /usr/src/app/node_modules
|
|
70
|
+
|
|
71
|
+
volumes:
|
|
72
|
+
weaviate_data_social-sweep:
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 🔄 Automatic Configuration
|
|
76
|
+
|
|
77
|
+
The framework automatically detects the environment and configures the connection:
|
|
78
|
+
|
|
79
|
+
### Environment Detection
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// The framework automatically detects:
|
|
83
|
+
const isDockerEnv =
|
|
84
|
+
process.env.NODE_ENV === "production" ||
|
|
85
|
+
process.env.DOCKER_ENV ||
|
|
86
|
+
process.env.HOSTNAME?.includes("docker") ||
|
|
87
|
+
process.env.HOSTNAME?.length === 12; // Docker container IDs
|
|
88
|
+
|
|
89
|
+
const defaultHost = isDockerEnv ? "weaviate" : "localhost";
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Configuration Priority
|
|
93
|
+
|
|
94
|
+
1. **Environment Variables** (highest priority)
|
|
95
|
+
- `WEAVIATE_HOST`
|
|
96
|
+
- `WEAVIATE_PORT`
|
|
97
|
+
- `WEAVIATE_SCHEME`
|
|
98
|
+
|
|
99
|
+
2. **Automatic Detection** (fallback)
|
|
100
|
+
- Docker environment detection
|
|
101
|
+
- Default to `localhost:8080` for local development
|
|
102
|
+
|
|
103
|
+
## 🚀 Initialization
|
|
104
|
+
|
|
105
|
+
### Basic Setup
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { WeaviateConfigService } from "./WeaviateConfig.js";
|
|
109
|
+
|
|
110
|
+
// Initialize with environment variables
|
|
111
|
+
await WeaviateConfigService.initializeClient();
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Custom Configuration
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { WeaviateConfigService } from "./WeaviateConfig.js";
|
|
118
|
+
|
|
119
|
+
// Initialize with custom config
|
|
120
|
+
await WeaviateConfigService.initializeClient({
|
|
121
|
+
host: "custom-weaviate-host",
|
|
122
|
+
port: 8080,
|
|
123
|
+
scheme: "https",
|
|
124
|
+
apiKey: "your-api-key",
|
|
125
|
+
multiTenancy: {
|
|
126
|
+
enabled: true,
|
|
127
|
+
autoTenantCreation: true,
|
|
128
|
+
autoTenantActivation: true,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 🏢 Multi-Tenancy Configuration
|
|
134
|
+
|
|
135
|
+
### Environment Variables
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Enable multi-tenancy globally
|
|
139
|
+
WEAVIATE_MULTI_TENANCY_ENABLED=true
|
|
140
|
+
|
|
141
|
+
# Auto-create tenants when objects are inserted
|
|
142
|
+
WEAVIATE_AUTO_TENANT_CREATION=true
|
|
143
|
+
|
|
144
|
+
# Auto-activate inactive tenants
|
|
145
|
+
WEAVIATE_AUTO_TENANT_ACTIVATION=true
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Schema-Level Configuration
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
const schema = {
|
|
152
|
+
name: "UserDocuments",
|
|
153
|
+
multiTenancy: {
|
|
154
|
+
enabled: true,
|
|
155
|
+
autoTenantCreation: true,
|
|
156
|
+
autoTenantActivation: true,
|
|
157
|
+
},
|
|
158
|
+
// ... other schema config
|
|
159
|
+
};
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Tenant Management
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// Create tenants
|
|
166
|
+
await weaviate.createTenant("UserDocuments", { name: "acme-corp" });
|
|
167
|
+
|
|
168
|
+
// List tenants
|
|
169
|
+
const tenants = await weaviate.listTenants("UserDocuments");
|
|
170
|
+
|
|
171
|
+
// Update tenant status
|
|
172
|
+
await weaviate.updateTenant("UserDocuments", "acme-corp", {
|
|
173
|
+
activityStatus: "COLD",
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## 🔍 Health Checks
|
|
178
|
+
|
|
179
|
+
### Connection Testing
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import { WeaviateConfigService } from "./WeaviateConfig.js";
|
|
183
|
+
|
|
184
|
+
// Test connection
|
|
185
|
+
const isHealthy = await WeaviateConfigService.healthCheck();
|
|
186
|
+
console.log("Weaviate connection:", isHealthy ? "✅ Healthy" : "❌ Failed");
|
|
187
|
+
|
|
188
|
+
// Get cluster information
|
|
189
|
+
const clusterInfo = await WeaviateConfigService.getClusterInfo();
|
|
190
|
+
console.log("Cluster info:", clusterInfo);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## 🛠️ Troubleshooting
|
|
194
|
+
|
|
195
|
+
### Common Issues
|
|
196
|
+
|
|
197
|
+
#### Connection Refused
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Check if Weaviate is running
|
|
201
|
+
docker ps | grep weaviate
|
|
202
|
+
|
|
203
|
+
# Check Weaviate logs
|
|
204
|
+
docker logs social-sweep-weaviate
|
|
205
|
+
|
|
206
|
+
# Test connection manually
|
|
207
|
+
curl http://localhost:8080/v1/meta
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
#### Environment Variables Not Loaded
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Check if .env file exists
|
|
214
|
+
ls -la .env
|
|
215
|
+
|
|
216
|
+
# Verify environment variables
|
|
217
|
+
docker exec social-sweep-api printenv | grep WEAVIATE
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### Docker Service Name Issues
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# Check Docker network
|
|
224
|
+
docker network ls
|
|
225
|
+
|
|
226
|
+
# Inspect container network
|
|
227
|
+
docker inspect social-sweep-api | grep NetworkMode
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Debug Mode
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
// Enable debug logging
|
|
234
|
+
process.env.DEBUG = "weaviate:*";
|
|
235
|
+
|
|
236
|
+
// Or add to your .env file
|
|
237
|
+
DEBUG=weaviate:*
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## 📊 Performance Tuning
|
|
241
|
+
|
|
242
|
+
### Connection Pooling
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
// The framework automatically handles connection pooling
|
|
246
|
+
// No additional configuration needed
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Timeout Configuration
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
// Default timeouts (can be customized in WeaviateConfig)
|
|
253
|
+
const config = {
|
|
254
|
+
host: "weaviate",
|
|
255
|
+
port: 8080,
|
|
256
|
+
scheme: "http",
|
|
257
|
+
timeout: 30000, // 30 seconds
|
|
258
|
+
};
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## 🔐 Security
|
|
262
|
+
|
|
263
|
+
### API Key Authentication
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
# Add to your .env file
|
|
267
|
+
WEAVIATE_API_KEY=your-secure-api-key
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Custom Headers
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# Add to your .env file
|
|
274
|
+
WEAVIATE_HEADERS={"Authorization": "Bearer your-token", "X-Custom-Header": "value"}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### HTTPS Configuration
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# For production environments
|
|
281
|
+
WEAVIATE_SCHEME=https
|
|
282
|
+
WEAVIATE_HOST=your-secure-weaviate-host.com
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## 📝 Configuration Examples
|
|
286
|
+
|
|
287
|
+
### Development Environment
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
# .env for local development
|
|
291
|
+
WEAVIATE_HOST=localhost
|
|
292
|
+
WEAVIATE_PORT=8080
|
|
293
|
+
WEAVIATE_SCHEME=http
|
|
294
|
+
NODE_ENV=development
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Production Environment
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# .env for production
|
|
301
|
+
WEAVIATE_HOST=weaviate-cluster.prod.com
|
|
302
|
+
WEAVIATE_PORT=8080
|
|
303
|
+
WEAVIATE_SCHEME=https
|
|
304
|
+
WEAVIATE_API_KEY=prod-api-key
|
|
305
|
+
NODE_ENV=production
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Docker Environment
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
# .env for Docker
|
|
312
|
+
WEAVIATE_HOST=weaviate
|
|
313
|
+
WEAVIATE_PORT=8080
|
|
314
|
+
WEAVIATE_SCHEME=http
|
|
315
|
+
NODE_ENV=production
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
**Next Steps**: Once configured, proceed to the [Schema Guide](./SCHEMA_GUIDE.md) to learn how to define your data schemas.
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# Error Handling in Weaviate Library
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Weaviate library now uses a consistent, structured approach to error handling through the `WeaviateError` class. This provides better error messages, programmatic error handling, and improved debugging.
|
|
6
|
+
|
|
7
|
+
## WeaviateError Class
|
|
8
|
+
|
|
9
|
+
The `WeaviateError` class extends the native `Error` class and provides:
|
|
10
|
+
- **Error Codes**: Enum-based error codes for programmatic handling
|
|
11
|
+
- **Details**: Additional context about the error (including original error)
|
|
12
|
+
- **Stack Traces**: Proper stack trace preservation
|
|
13
|
+
- **Helper Methods**: Utilities for error type checking and conversion
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { WeaviateError, WeaviateErrorCode } from '@weaviate/lib';
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
await weaviate.createObject({ class: 'Person', properties: { name: 'John' } });
|
|
22
|
+
} catch (error) {
|
|
23
|
+
if (error instanceof WeaviateError) {
|
|
24
|
+
console.log('Error Code:', error.code);
|
|
25
|
+
console.log('Message:', error.message);
|
|
26
|
+
console.log('Details:', error.details);
|
|
27
|
+
|
|
28
|
+
// Check specific error type
|
|
29
|
+
if (error.is(WeaviateErrorCode.OBJECT_CREATION_ERROR)) {
|
|
30
|
+
// Handle object creation errors
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Error Codes
|
|
37
|
+
|
|
38
|
+
### Schema Errors
|
|
39
|
+
- `SCHEMA_VALIDATION_ERROR` - Schema failed validation
|
|
40
|
+
- `SCHEMA_CREATION_ERROR` - Failed to create schema
|
|
41
|
+
- `SCHEMA_NOT_FOUND` - Schema doesn't exist
|
|
42
|
+
|
|
43
|
+
### Search Errors
|
|
44
|
+
- `SEARCH_ERROR` - General search operation failed
|
|
45
|
+
- `INVALID_SEARCH_METHOD` - Invalid search method specified
|
|
46
|
+
|
|
47
|
+
### CRUD Errors
|
|
48
|
+
- `OBJECT_CREATION_ERROR` - Failed to create object
|
|
49
|
+
- `OBJECT_UPDATE_ERROR` - Failed to update object
|
|
50
|
+
- `OBJECT_DELETE_ERROR` - Failed to delete object
|
|
51
|
+
- `OBJECT_RETRIEVAL_ERROR` - Failed to retrieve object
|
|
52
|
+
- `BATCH_OPERATION_ERROR` - Batch operation failed
|
|
53
|
+
|
|
54
|
+
### Tenant Errors
|
|
55
|
+
- `TENANT_CREATION_ERROR` - Failed to create tenant
|
|
56
|
+
- `TENANT_UPDATE_ERROR` - Failed to update tenant
|
|
57
|
+
- `TENANT_DELETE_ERROR` - Failed to delete tenant
|
|
58
|
+
- `TENANT_RETRIEVAL_ERROR` - Failed to retrieve tenant
|
|
59
|
+
- `TENANT_VALIDATION_ERROR` - Tenant name validation failed
|
|
60
|
+
- `TENANT_NOT_FOUND` - Tenant doesn't exist
|
|
61
|
+
|
|
62
|
+
### General Errors
|
|
63
|
+
- `UNKNOWN_ERROR` - Unclassified error
|
|
64
|
+
- `VALIDATION_ERROR` - General validation error
|
|
65
|
+
- `CONNECTION_ERROR` - Connection to Weaviate failed
|
|
66
|
+
|
|
67
|
+
## Error Handling Patterns
|
|
68
|
+
|
|
69
|
+
### Standard Pattern
|
|
70
|
+
|
|
71
|
+
All Weaviate methods follow this consistent pattern:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
async someMethod(params): Promise<Result> {
|
|
75
|
+
try {
|
|
76
|
+
// Operation
|
|
77
|
+
const result = await this.client.doSomething();
|
|
78
|
+
return result;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
Logger.log("Context about the operation:", error);
|
|
81
|
+
throw WeaviateError.from(
|
|
82
|
+
error,
|
|
83
|
+
WeaviateErrorCode.APPROPRIATE_ERROR_CODE,
|
|
84
|
+
"Human-readable error message with context"
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Benefits
|
|
91
|
+
|
|
92
|
+
1. **Consistent Logging**: All errors are logged with context before being thrown
|
|
93
|
+
2. **Structured Errors**: Errors include error codes for programmatic handling
|
|
94
|
+
3. **Context Preservation**: Original errors are preserved in the `details` field
|
|
95
|
+
4. **Type Safety**: TypeScript IntelliSense provides autocomplete for error codes
|
|
96
|
+
|
|
97
|
+
### Error Wrapping
|
|
98
|
+
|
|
99
|
+
The `WeaviateError.from()` helper safely wraps any error type:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
// Handles WeaviateError (pass-through)
|
|
103
|
+
// Handles Error (wraps with message)
|
|
104
|
+
// Handles unknown types (converts to string)
|
|
105
|
+
throw WeaviateError.from(
|
|
106
|
+
error,
|
|
107
|
+
WeaviateErrorCode.SEARCH_ERROR,
|
|
108
|
+
`Failed to search ${schemaName}`
|
|
109
|
+
);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Examples
|
|
113
|
+
|
|
114
|
+
### Basic Error Handling
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
try {
|
|
118
|
+
const results = await weaviate.search('Person', {
|
|
119
|
+
method: 'hybrid',
|
|
120
|
+
options: { hybrid: { query: 'engineer' }, limit: 10 }
|
|
121
|
+
});
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (error instanceof WeaviateError) {
|
|
124
|
+
console.error(`Error ${error.code}: ${error.message}`);
|
|
125
|
+
|
|
126
|
+
// Log details for debugging
|
|
127
|
+
console.error('Details:', error.details);
|
|
128
|
+
} else {
|
|
129
|
+
// Unexpected error type
|
|
130
|
+
console.error('Unexpected error:', error);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Type-Specific Error Handling
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
try {
|
|
139
|
+
await weaviate.createObject({
|
|
140
|
+
class: 'Person',
|
|
141
|
+
properties: { name: 'John Doe' }
|
|
142
|
+
});
|
|
143
|
+
} catch (error) {
|
|
144
|
+
if (error instanceof WeaviateError) {
|
|
145
|
+
switch (error.code) {
|
|
146
|
+
case WeaviateErrorCode.OBJECT_CREATION_ERROR:
|
|
147
|
+
// Handle creation errors (maybe retry)
|
|
148
|
+
break;
|
|
149
|
+
case WeaviateErrorCode.VALIDATION_ERROR:
|
|
150
|
+
// Handle validation errors (fix input)
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
// Handle other errors
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Error Serialization
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
try {
|
|
164
|
+
// ... operation
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (error instanceof WeaviateError) {
|
|
167
|
+
// Send to logging service
|
|
168
|
+
logger.error(JSON.stringify(error.toJSON()));
|
|
169
|
+
|
|
170
|
+
// Or send to client
|
|
171
|
+
res.status(500).json(error.toJSON());
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Migration from Old Error Handling
|
|
177
|
+
|
|
178
|
+
### Before (Inconsistent)
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
// Pattern 1: Log and throw
|
|
182
|
+
catch (error) {
|
|
183
|
+
Logger.log("Error:", error);
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Pattern 2: Log and return error object
|
|
188
|
+
catch (error) {
|
|
189
|
+
Logger.log("Error:", error);
|
|
190
|
+
return { success: false, error: error.message };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Pattern 3: Just throw
|
|
194
|
+
catch (error) {
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### After (Consistent)
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
// Consistent pattern everywhere
|
|
203
|
+
catch (error) {
|
|
204
|
+
Logger.log("Descriptive context:", error);
|
|
205
|
+
throw WeaviateError.from(
|
|
206
|
+
error,
|
|
207
|
+
WeaviateErrorCode.APPROPRIATE_CODE,
|
|
208
|
+
"Clear message with context"
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Best Practices
|
|
214
|
+
|
|
215
|
+
1. **Always Use Error Codes**: Choose the most specific error code available
|
|
216
|
+
2. **Provide Context**: Include relevant parameters in error messages
|
|
217
|
+
3. **Log Before Throwing**: Always log with context before throwing
|
|
218
|
+
4. **Preserve Original Error**: The original error is automatically preserved in `details`
|
|
219
|
+
5. **Type Check**: Use `instanceof WeaviateError` to check error type
|
|
220
|
+
6. **Use Helper Methods**: Use `error.is(code)` for clean type checking
|
|
221
|
+
|
|
222
|
+
## Testing Errors
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import { describe, it, expect } from 'vitest';
|
|
226
|
+
import { WeaviateError, WeaviateErrorCode } from './lib/weaviate';
|
|
227
|
+
|
|
228
|
+
describe('Error Handling', () => {
|
|
229
|
+
it('should throw WeaviateError with correct code', async () => {
|
|
230
|
+
await expect(
|
|
231
|
+
weaviate.search('NonExistent', { method: 'vector', options: {} })
|
|
232
|
+
).rejects.toThrow(WeaviateError);
|
|
233
|
+
|
|
234
|
+
await expect(
|
|
235
|
+
weaviate.search('NonExistent', { method: 'vector', options: {} })
|
|
236
|
+
).rejects.toMatchObject({
|
|
237
|
+
code: WeaviateErrorCode.SEARCH_ERROR
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Error Handling Guidelines
|
|
244
|
+
|
|
245
|
+
### For Library Developers
|
|
246
|
+
|
|
247
|
+
1. **Never swallow errors**: Always either handle or rethrow with context
|
|
248
|
+
2. **Use appropriate codes**: Select the most specific error code
|
|
249
|
+
3. **Add context**: Include parameter values in error messages
|
|
250
|
+
4. **Test error paths**: Write tests for error scenarios
|
|
251
|
+
5. **Document errors**: Document what errors methods can throw
|
|
252
|
+
|
|
253
|
+
### For Library Users
|
|
254
|
+
|
|
255
|
+
1. **Catch WeaviateError**: Use type guards to handle errors properly
|
|
256
|
+
2. **Check error codes**: Use error codes for conditional logic
|
|
257
|
+
3. **Log details**: The `details` field contains the original error
|
|
258
|
+
4. **Don't rely on message**: Error messages may change; use codes
|
|
259
|
+
5. **Handle gracefully**: Provide meaningful feedback to end users
|
|
260
|
+
|
|
261
|
+
## Conclusion
|
|
262
|
+
|
|
263
|
+
The new error handling system provides:
|
|
264
|
+
- ✅ Consistent error handling patterns
|
|
265
|
+
- ✅ Better debugging with error codes
|
|
266
|
+
- ✅ Preserved stack traces and context
|
|
267
|
+
- ✅ Type-safe error checking
|
|
268
|
+
- ✅ Improved developer experience
|
|
269
|
+
|
|
270
|
+
All methods in the Weaviate library now follow these patterns, making it easier to build robust applications.
|
|
271
|
+
|