@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,630 @@
|
|
|
1
|
+
# Schema Guide
|
|
2
|
+
|
|
3
|
+
This guide covers how to create, manage, and optimize schemas for the Weaviate framework.
|
|
4
|
+
|
|
5
|
+
## ๐ Schema Basics
|
|
6
|
+
|
|
7
|
+
### What is a Schema?
|
|
8
|
+
|
|
9
|
+
A schema defines the structure of your data in Weaviate, including:
|
|
10
|
+
|
|
11
|
+
- **Properties**: Fields and their types
|
|
12
|
+
- **Vectorization**: How text is converted to vectors
|
|
13
|
+
- **Indexing**: How data is indexed for search
|
|
14
|
+
- **Relationships**: Connections between different data types
|
|
15
|
+
|
|
16
|
+
### Schema Structure
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
interface SchemaConfig {
|
|
20
|
+
name: string; // Schema name (e.g., "Person")
|
|
21
|
+
description?: string; // Human-readable description
|
|
22
|
+
vectorizer?: Vectorizer; // Vectorization configuration
|
|
23
|
+
vectorIndexConfig?: VectorIndexConfig; // Index settings
|
|
24
|
+
properties: SearchableField[]; // Data fields
|
|
25
|
+
searchableFields?: string[]; // Fields to include in search
|
|
26
|
+
filterableFields?: string[]; // Fields for filtering
|
|
27
|
+
sortableFields?: string[]; // Fields for sorting
|
|
28
|
+
relationships?: {
|
|
29
|
+
// Schema relationships
|
|
30
|
+
[fieldName: string]: {
|
|
31
|
+
targetClass: string;
|
|
32
|
+
type: "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many";
|
|
33
|
+
required?: boolean;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
plugins?: string[]; // Custom plugins
|
|
37
|
+
metadata?: Record<string, any>; // Additional metadata
|
|
38
|
+
multiTenancy?: MultiTenancyConfig; // Multi-tenancy configuration
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## ๐๏ธ Creating Schemas
|
|
43
|
+
|
|
44
|
+
### Basic Schema Example
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
// src/config/schemas/Person.ts
|
|
48
|
+
import { SchemaConfig } from "../../lib/weaviate/types/index.js";
|
|
49
|
+
|
|
50
|
+
const Person: SchemaConfig = {
|
|
51
|
+
name: "Person",
|
|
52
|
+
description: "Individual person with profile information",
|
|
53
|
+
properties: [
|
|
54
|
+
{
|
|
55
|
+
name: "firstName",
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "Person's first name",
|
|
58
|
+
searchable: true,
|
|
59
|
+
filterable: true,
|
|
60
|
+
sortable: true,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "lastName",
|
|
64
|
+
type: "string",
|
|
65
|
+
description: "Person's last name",
|
|
66
|
+
searchable: true,
|
|
67
|
+
filterable: true,
|
|
68
|
+
sortable: true,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "email",
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "Email address",
|
|
74
|
+
searchable: true,
|
|
75
|
+
filterable: true,
|
|
76
|
+
unique: true,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "bio",
|
|
80
|
+
type: "text",
|
|
81
|
+
description: "Personal biography",
|
|
82
|
+
searchable: true,
|
|
83
|
+
vectorizable: true,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "skills",
|
|
87
|
+
type: "string[]",
|
|
88
|
+
description: "List of skills",
|
|
89
|
+
searchable: true,
|
|
90
|
+
filterable: true,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "createdAt",
|
|
94
|
+
type: "date",
|
|
95
|
+
description: "Creation timestamp",
|
|
96
|
+
filterable: true,
|
|
97
|
+
sortable: true,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
searchableFields: ["firstName", "lastName", "email", "bio", "skills"],
|
|
101
|
+
filterableFields: ["firstName", "lastName", "email", "skills", "createdAt"],
|
|
102
|
+
sortableFields: ["firstName", "lastName", "createdAt"],
|
|
103
|
+
};
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Advanced Schema with Relationships
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// src/config/schemas/Organization.ts
|
|
110
|
+
import { SchemaConfig } from "../../lib/weaviate/types/index.js";
|
|
111
|
+
|
|
112
|
+
const Organization: SchemaConfig = {
|
|
113
|
+
name: "Organization",
|
|
114
|
+
description: "Company or organization",
|
|
115
|
+
properties: [
|
|
116
|
+
{
|
|
117
|
+
name: "name",
|
|
118
|
+
type: "string",
|
|
119
|
+
description: "Organization name",
|
|
120
|
+
searchable: true,
|
|
121
|
+
filterable: true,
|
|
122
|
+
sortable: true,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "description",
|
|
126
|
+
type: "text",
|
|
127
|
+
description: "Organization description",
|
|
128
|
+
searchable: true,
|
|
129
|
+
vectorizable: true,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "industry",
|
|
133
|
+
type: "string",
|
|
134
|
+
description: "Industry sector",
|
|
135
|
+
searchable: true,
|
|
136
|
+
filterable: true,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "size",
|
|
140
|
+
type: "string",
|
|
141
|
+
description: "Company size",
|
|
142
|
+
filterable: true,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "website",
|
|
146
|
+
type: "string",
|
|
147
|
+
description: "Company website",
|
|
148
|
+
filterable: true,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
relationships: {
|
|
152
|
+
employees: {
|
|
153
|
+
targetClass: "Person",
|
|
154
|
+
type: "one-to-many",
|
|
155
|
+
required: false,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
searchableFields: ["name", "description", "industry"],
|
|
159
|
+
filterableFields: ["name", "industry", "size"],
|
|
160
|
+
sortableFields: ["name", "size"],
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Multi-Tenant Schema Example
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
// src/config/schemas/UserDocuments.ts
|
|
168
|
+
import { SchemaConfig } from "../../lib/weaviate/types/index.js";
|
|
169
|
+
|
|
170
|
+
const UserDocuments: SchemaConfig = {
|
|
171
|
+
name: "UserDocuments",
|
|
172
|
+
description: "User documents with multi-tenancy enabled",
|
|
173
|
+
vectorizer: "text2vec-openai",
|
|
174
|
+
properties: [
|
|
175
|
+
{
|
|
176
|
+
name: "title",
|
|
177
|
+
type: "string",
|
|
178
|
+
description: "Document title",
|
|
179
|
+
searchable: true,
|
|
180
|
+
filterable: true,
|
|
181
|
+
sortable: true,
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: "content",
|
|
185
|
+
type: "text",
|
|
186
|
+
description: "Document content",
|
|
187
|
+
searchable: true,
|
|
188
|
+
vectorizable: true,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "category",
|
|
192
|
+
type: "string",
|
|
193
|
+
description: "Document category",
|
|
194
|
+
searchable: true,
|
|
195
|
+
filterable: true,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "createdAt",
|
|
199
|
+
type: "date",
|
|
200
|
+
description: "Creation timestamp",
|
|
201
|
+
filterable: true,
|
|
202
|
+
sortable: true,
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
multiTenancy: {
|
|
206
|
+
enabled: true,
|
|
207
|
+
autoTenantCreation: true,
|
|
208
|
+
autoTenantActivation: true,
|
|
209
|
+
},
|
|
210
|
+
searchableFields: ["title", "content", "category"],
|
|
211
|
+
filterableFields: ["title", "category", "createdAt"],
|
|
212
|
+
sortableFields: ["title", "createdAt"],
|
|
213
|
+
};
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## ๐ง Field Types
|
|
217
|
+
|
|
218
|
+
### Supported Field Types
|
|
219
|
+
|
|
220
|
+
| Type | Description | Searchable | Filterable | Vectorizable |
|
|
221
|
+
| ---------------- | ---------------- | ---------- | ---------- | ------------ |
|
|
222
|
+
| `string` | Short text | โ
| โ
| โ |
|
|
223
|
+
| `text` | Long text | โ
| โ | โ
|
|
|
224
|
+
| `string[]` | Array of strings | โ
| โ
| โ |
|
|
225
|
+
| `int` | Integer number | โ | โ
| โ |
|
|
226
|
+
| `float` | Decimal number | โ | โ
| โ |
|
|
227
|
+
| `boolean` | True/false | โ | โ
| โ |
|
|
228
|
+
| `date` | Date/time | โ | โ
| โ |
|
|
229
|
+
| `geoCoordinates` | GPS coordinates | โ | โ
| โ |
|
|
230
|
+
|
|
231
|
+
### Field Configuration
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
interface SearchableField {
|
|
235
|
+
name: string; // Field name
|
|
236
|
+
type: string; // Field type
|
|
237
|
+
description?: string; // Human-readable description
|
|
238
|
+
searchable?: boolean; // Include in search (default: false)
|
|
239
|
+
filterable?: boolean; // Allow filtering (default: false)
|
|
240
|
+
sortable?: boolean; // Allow sorting (default: false)
|
|
241
|
+
vectorizable?: boolean; // Include in vectorization (default: false)
|
|
242
|
+
unique?: boolean; // Enforce uniqueness (default: false)
|
|
243
|
+
required?: boolean; // Required field (default: false)
|
|
244
|
+
defaultValue?: any; // Default value
|
|
245
|
+
validation?: {
|
|
246
|
+
// Custom validation rules
|
|
247
|
+
min?: number;
|
|
248
|
+
max?: number;
|
|
249
|
+
pattern?: string;
|
|
250
|
+
enum?: string[];
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## ๐ฏ Vectorization
|
|
256
|
+
|
|
257
|
+
### Text Vectorization
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
const Person: SchemaConfig = {
|
|
261
|
+
name: "Person",
|
|
262
|
+
vectorizer: {
|
|
263
|
+
module: "text2vec-openai", // or text2vec-cohere, text2vec-huggingface
|
|
264
|
+
config: {
|
|
265
|
+
model: "text-embedding-ada-002",
|
|
266
|
+
dimensions: 1536,
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
properties: [
|
|
270
|
+
{
|
|
271
|
+
name: "bio",
|
|
272
|
+
type: "text",
|
|
273
|
+
vectorizable: true, // This field will be vectorized
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
};
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Vector Index Configuration
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
const Person: SchemaConfig = {
|
|
283
|
+
name: "Person",
|
|
284
|
+
vectorIndexConfig: {
|
|
285
|
+
distance: "cosine", // cosine, dot, l2-squared
|
|
286
|
+
efConstruction: 128, // Build-time parameter
|
|
287
|
+
maxConnections: 16, // Maximum connections per node
|
|
288
|
+
ef: 64, // Query-time parameter
|
|
289
|
+
},
|
|
290
|
+
// ... rest of schema
|
|
291
|
+
};
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## ๐ Relationships
|
|
295
|
+
|
|
296
|
+
### One-to-One Relationship
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
const Person: SchemaConfig = {
|
|
300
|
+
name: "Person",
|
|
301
|
+
properties: [
|
|
302
|
+
{
|
|
303
|
+
name: "profile",
|
|
304
|
+
type: "object",
|
|
305
|
+
description: "Personal profile information",
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
relationships: {
|
|
309
|
+
profile: {
|
|
310
|
+
targetClass: "Profile",
|
|
311
|
+
type: "one-to-one",
|
|
312
|
+
required: false,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### One-to-Many Relationship
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
const Organization: SchemaConfig = {
|
|
322
|
+
name: "Organization",
|
|
323
|
+
relationships: {
|
|
324
|
+
employees: {
|
|
325
|
+
targetClass: "Person",
|
|
326
|
+
type: "one-to-many",
|
|
327
|
+
required: false,
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Many-to-Many Relationship
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
const Person: SchemaConfig = {
|
|
337
|
+
name: "Person",
|
|
338
|
+
relationships: {
|
|
339
|
+
skills: {
|
|
340
|
+
targetClass: "Skill",
|
|
341
|
+
type: "many-to-many",
|
|
342
|
+
required: false,
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
## ๐ Schema Organization
|
|
349
|
+
|
|
350
|
+
### File Structure
|
|
351
|
+
|
|
352
|
+
```
|
|
353
|
+
src/config/schemas/
|
|
354
|
+
โโโ index.ts # Export all schemas
|
|
355
|
+
โโโ Person.ts # Person schema
|
|
356
|
+
โโโ Organization.ts # Organization schema
|
|
357
|
+
โโโ Conversation.ts # Conversation schema
|
|
358
|
+
โโโ Message.ts # Message schema
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Schema Index
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
// src/config/schemas/index.ts
|
|
365
|
+
export { default as Person } from "./Person.js";
|
|
366
|
+
export { default as Organization } from "./Organization.js";
|
|
367
|
+
export { default as Conversation } from "./Conversation.js";
|
|
368
|
+
export { default as Message } from "./Message.js";
|
|
369
|
+
|
|
370
|
+
import Person from "./Person.js";
|
|
371
|
+
import Organization from "./Organization.js";
|
|
372
|
+
import Conversation from "./Conversation.js";
|
|
373
|
+
import Message from "./Message.js";
|
|
374
|
+
|
|
375
|
+
// Export schemas as an array for easier consumption
|
|
376
|
+
export const schemas = [Person, Organization, Conversation, Message];
|
|
377
|
+
|
|
378
|
+
export default schemas;
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## ๐ข Multi-Tenancy Configuration
|
|
382
|
+
|
|
383
|
+
### Basic Multi-Tenant Schema
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
const UserDocuments: SchemaConfig = {
|
|
387
|
+
name: "UserDocuments",
|
|
388
|
+
multiTenancy: {
|
|
389
|
+
enabled: true,
|
|
390
|
+
autoTenantCreation: true,
|
|
391
|
+
autoTenantActivation: true,
|
|
392
|
+
},
|
|
393
|
+
// ... rest of schema
|
|
394
|
+
};
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Multi-Tenancy Options
|
|
398
|
+
|
|
399
|
+
- **`enabled`**: Enable multi-tenancy for this schema
|
|
400
|
+
- **`autoTenantCreation`**: Automatically create tenants when objects are inserted
|
|
401
|
+
- **`autoTenantActivation`**: Automatically activate inactive tenants
|
|
402
|
+
|
|
403
|
+
### Tenant Management
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
// Create tenants for different organizations
|
|
407
|
+
await weaviate.createTenant("UserDocuments", { name: "acme-corp" });
|
|
408
|
+
await weaviate.createTenant("UserDocuments", { name: "beta-llc" });
|
|
409
|
+
|
|
410
|
+
// List all tenants
|
|
411
|
+
const tenants = await weaviate.listTenants("UserDocuments");
|
|
412
|
+
|
|
413
|
+
// Update tenant activity status
|
|
414
|
+
await weaviate.updateTenant("UserDocuments", "acme-corp", {
|
|
415
|
+
activityStatus: "COLD", // Move to cold storage
|
|
416
|
+
});
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### Tenant-Aware Operations
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
// Search within a specific tenant
|
|
423
|
+
const results = await weaviate.searchWithTenant(
|
|
424
|
+
"UserDocuments",
|
|
425
|
+
"hybrid",
|
|
426
|
+
{
|
|
427
|
+
hybrid: { query: "machine learning", alpha: 0.5 },
|
|
428
|
+
},
|
|
429
|
+
"acme-corp",
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
// Smart search with tenant context
|
|
433
|
+
const smartResults = await weaviate.smartSearchWithTenant(
|
|
434
|
+
"UserDocuments",
|
|
435
|
+
"AI expert",
|
|
436
|
+
"acme-corp",
|
|
437
|
+
);
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## ๐ Plugin Integration
|
|
441
|
+
|
|
442
|
+
### Built-in Plugins
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
const Person: SchemaConfig = {
|
|
446
|
+
name: "Person",
|
|
447
|
+
plugins: [
|
|
448
|
+
"personEnrichment", // Automatic profile analysis
|
|
449
|
+
"conversationAnalysis", // Activity level analysis
|
|
450
|
+
],
|
|
451
|
+
// ... rest of schema
|
|
452
|
+
};
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### Custom Plugin Integration
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
const CustomSchema: SchemaConfig = {
|
|
459
|
+
name: "CustomData",
|
|
460
|
+
plugins: [
|
|
461
|
+
"customEnrichment", // Your custom plugin
|
|
462
|
+
"dataValidation", // Another custom plugin
|
|
463
|
+
],
|
|
464
|
+
// ... rest of schema
|
|
465
|
+
};
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## ๐ Schema Registration
|
|
469
|
+
|
|
470
|
+
### Automatic Registration
|
|
471
|
+
|
|
472
|
+
```typescript
|
|
473
|
+
// In your application bootstrap
|
|
474
|
+
import Weaviate from "./lib/weaviate/Weaviate.js";
|
|
475
|
+
import { schemas } from "./config/schemas/index.js";
|
|
476
|
+
|
|
477
|
+
const weaviate = new Weaviate();
|
|
478
|
+
await weaviate.initializeSchemas(schemas);
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
### Manual Registration
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
// Register individual schemas
|
|
485
|
+
weaviate.registerSchema(customSchema);
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
## ๐ Schema Optimization
|
|
489
|
+
|
|
490
|
+
### Search Performance
|
|
491
|
+
|
|
492
|
+
```typescript
|
|
493
|
+
// Optimize for search performance
|
|
494
|
+
const Person: SchemaConfig = {
|
|
495
|
+
name: "Person",
|
|
496
|
+
searchableFields: [
|
|
497
|
+
"firstName", // High-frequency searches
|
|
498
|
+
"lastName", // High-frequency searches
|
|
499
|
+
"email", // Unique identifier
|
|
500
|
+
"bio", // Rich content for semantic search
|
|
501
|
+
],
|
|
502
|
+
// ... rest of schema
|
|
503
|
+
};
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### Filtering Performance
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
// Optimize for filtering
|
|
510
|
+
const Person: SchemaConfig = {
|
|
511
|
+
name: "Person",
|
|
512
|
+
filterableFields: [
|
|
513
|
+
"createdAt", // Date range filtering
|
|
514
|
+
"skills", // Category filtering
|
|
515
|
+
"location", // Geographic filtering
|
|
516
|
+
],
|
|
517
|
+
// ... rest of schema
|
|
518
|
+
};
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### Vectorization Strategy
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
// Strategic vectorization
|
|
525
|
+
const Person: SchemaConfig = {
|
|
526
|
+
name: "Person",
|
|
527
|
+
properties: [
|
|
528
|
+
{
|
|
529
|
+
name: "bio",
|
|
530
|
+
type: "text",
|
|
531
|
+
vectorizable: true, // Rich semantic content
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
name: "firstName",
|
|
535
|
+
type: "string",
|
|
536
|
+
vectorizable: false, // Exact matching better
|
|
537
|
+
},
|
|
538
|
+
],
|
|
539
|
+
};
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
## ๐งช Schema Testing
|
|
543
|
+
|
|
544
|
+
### Validation
|
|
545
|
+
|
|
546
|
+
```typescript
|
|
547
|
+
// Test schema validation
|
|
548
|
+
import { SchemaRegistry } from "./lib/weaviate/schemas/SchemaRegistry.js";
|
|
549
|
+
|
|
550
|
+
const registry = new SchemaRegistry(schemas);
|
|
551
|
+
const isValid = registry.validateSchema(Person);
|
|
552
|
+
console.log("Schema valid:", isValid);
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### Schema Information
|
|
556
|
+
|
|
557
|
+
```typescript
|
|
558
|
+
// Get schema information
|
|
559
|
+
const schemaInfo = weaviate.getSchemaInfo("Person");
|
|
560
|
+
console.log("Schema info:", schemaInfo);
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
## ๐ง Best Practices
|
|
564
|
+
|
|
565
|
+
### 1. Naming Conventions
|
|
566
|
+
|
|
567
|
+
```typescript
|
|
568
|
+
// Use PascalCase for schema names
|
|
569
|
+
const Person: SchemaConfig = { name: "Person" };
|
|
570
|
+
const Organization: SchemaConfig = { name: "Organization" };
|
|
571
|
+
|
|
572
|
+
// Use camelCase for field names
|
|
573
|
+
properties: [
|
|
574
|
+
{ name: "firstName", type: "string" },
|
|
575
|
+
{ name: "lastName", type: "string" },
|
|
576
|
+
{ name: "createdAt", type: "date" },
|
|
577
|
+
];
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
### 2. Field Selection
|
|
581
|
+
|
|
582
|
+
```typescript
|
|
583
|
+
// Only vectorize fields that benefit from semantic search
|
|
584
|
+
{
|
|
585
|
+
name: "bio",
|
|
586
|
+
type: "text",
|
|
587
|
+
vectorizable: true, // Rich semantic content
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Use exact matching for structured data
|
|
591
|
+
{
|
|
592
|
+
name: "email",
|
|
593
|
+
type: "string",
|
|
594
|
+
vectorizable: false, // Exact matching better
|
|
595
|
+
}
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### 3. Relationship Design
|
|
599
|
+
|
|
600
|
+
```typescript
|
|
601
|
+
// Design relationships for your use case
|
|
602
|
+
relationships: {
|
|
603
|
+
// One-to-many: Organization has many employees
|
|
604
|
+
employees: {
|
|
605
|
+
targetClass: "Person",
|
|
606
|
+
type: "one-to-many",
|
|
607
|
+
},
|
|
608
|
+
// Many-to-many: Person has many skills
|
|
609
|
+
skills: {
|
|
610
|
+
targetClass: "Skill",
|
|
611
|
+
type: "many-to-many",
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
### 4. Performance Considerations
|
|
617
|
+
|
|
618
|
+
```typescript
|
|
619
|
+
// Limit searchable fields to essential ones
|
|
620
|
+
searchableFields: [
|
|
621
|
+
"firstName", // Essential for person search
|
|
622
|
+
"lastName", // Essential for person search
|
|
623
|
+
"bio", // Rich content for semantic search
|
|
624
|
+
// Avoid: "createdAt", "id", etc.
|
|
625
|
+
];
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
---
|
|
629
|
+
|
|
630
|
+
**Next Steps**: Once your schemas are defined, proceed to the [Plugin Development Guide](./PLUGIN_DEVELOPMENT.md) to learn how to create custom plugins.
|