@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,547 @@
|
|
|
1
|
+
# Plugin Development Guide
|
|
2
|
+
|
|
3
|
+
This guide covers how to create, test, and deploy custom plugins for the Weaviate framework.
|
|
4
|
+
|
|
5
|
+
## 🔌 Plugin System Overview
|
|
6
|
+
|
|
7
|
+
### What are Plugins?
|
|
8
|
+
|
|
9
|
+
Plugins are extensible components that enhance your data during the search and indexing process. They can:
|
|
10
|
+
|
|
11
|
+
- **Enrich Data**: Add computed fields, scores, or metadata
|
|
12
|
+
- **Transform Content**: Modify text before vectorization
|
|
13
|
+
- **Add Analytics**: Calculate metrics and insights
|
|
14
|
+
- **Integrate External APIs**: Fetch additional data
|
|
15
|
+
- **Custom Processing**: Apply business logic
|
|
16
|
+
|
|
17
|
+
### Built-in Plugins
|
|
18
|
+
|
|
19
|
+
The framework does not include default built-in plugins. You can create and register custom plugins as needed.
|
|
20
|
+
|
|
21
|
+
## 🏗️ Plugin Architecture
|
|
22
|
+
|
|
23
|
+
### Plugin Interface
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
interface Plugin {
|
|
27
|
+
name: string; // Plugin identifier
|
|
28
|
+
version: string; // Plugin version
|
|
29
|
+
description?: string; // Plugin description
|
|
30
|
+
dependencies?: string[]; // Required dependencies
|
|
31
|
+
initialize?(context: PluginContext): Promise<void>;
|
|
32
|
+
process?(data: any, context: PluginContext): Promise<any>;
|
|
33
|
+
cleanup?(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Plugin Context
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
interface PluginContext {
|
|
41
|
+
schemaName: string; // Current schema being processed
|
|
42
|
+
operation: "create" | "update" | "search" | "delete";
|
|
43
|
+
metadata: Record<string, any>; // Additional context data
|
|
44
|
+
logger: Logger; // Logging interface
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 🚀 Creating Your First Plugin
|
|
49
|
+
|
|
50
|
+
### Basic Plugin Structure
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// src/lib/weaviate/plugins/MyCustomPlugin.ts
|
|
54
|
+
import { Plugin, PluginContext } from "../types/Plugin.js";
|
|
55
|
+
import Logger from "@sixthsummit/ship-api/app/utils/Logger";
|
|
56
|
+
|
|
57
|
+
export default class MyCustomPlugin implements Plugin {
|
|
58
|
+
name = "myCustomPlugin";
|
|
59
|
+
version = "1.0.0";
|
|
60
|
+
description = "My custom data enrichment plugin";
|
|
61
|
+
|
|
62
|
+
async initialize(context: PluginContext): Promise<void> {
|
|
63
|
+
Logger.log(`Initializing ${this.name} v${this.version}`);
|
|
64
|
+
// Setup plugin resources
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async process(data: any, context: PluginContext): Promise<any> {
|
|
68
|
+
Logger.log(`Processing data for ${context.schemaName}`);
|
|
69
|
+
|
|
70
|
+
// Your custom processing logic here
|
|
71
|
+
const enrichedData = this.enrichData(data);
|
|
72
|
+
|
|
73
|
+
return enrichedData;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async cleanup(): Promise<void> {
|
|
77
|
+
Logger.log(`Cleaning up ${this.name}`);
|
|
78
|
+
// Cleanup resources
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private enrichData(data: any): any {
|
|
82
|
+
// Add your custom enrichment logic
|
|
83
|
+
return {
|
|
84
|
+
...data,
|
|
85
|
+
enrichedAt: new Date().toISOString(),
|
|
86
|
+
customField: "processed by MyCustomPlugin",
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Advanced Plugin with External API
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
// src/lib/weaviate/plugins/ExternalDataPlugin.ts
|
|
96
|
+
import { Plugin, PluginContext } from "../types/Plugin.js";
|
|
97
|
+
import Logger from "@sixthsummit/ship-api/app/utils/Logger";
|
|
98
|
+
|
|
99
|
+
export default class ExternalDataPlugin implements Plugin {
|
|
100
|
+
name = "externalDataPlugin";
|
|
101
|
+
version = "1.0.0";
|
|
102
|
+
description = "Enriches data with external API information";
|
|
103
|
+
|
|
104
|
+
private apiKey: string;
|
|
105
|
+
private baseUrl: string;
|
|
106
|
+
|
|
107
|
+
async initialize(context: PluginContext): Promise<void> {
|
|
108
|
+
this.apiKey = process.env.EXTERNAL_API_KEY || "";
|
|
109
|
+
this.baseUrl = process.env.EXTERNAL_API_URL || "";
|
|
110
|
+
|
|
111
|
+
if (!this.apiKey) {
|
|
112
|
+
throw new Error("EXTERNAL_API_KEY environment variable is required");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
Logger.log(`Initialized ${this.name} with API: ${this.baseUrl}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async process(data: any, context: PluginContext): Promise<any> {
|
|
119
|
+
try {
|
|
120
|
+
// Only process Person schemas
|
|
121
|
+
if (context.schemaName !== "Person") {
|
|
122
|
+
return data;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Fetch external data
|
|
126
|
+
const externalData = await this.fetchExternalData(data.email);
|
|
127
|
+
|
|
128
|
+
// Merge with original data
|
|
129
|
+
return {
|
|
130
|
+
...data,
|
|
131
|
+
externalData: {
|
|
132
|
+
company: externalData.company,
|
|
133
|
+
industry: externalData.industry,
|
|
134
|
+
location: externalData.location,
|
|
135
|
+
lastUpdated: new Date().toISOString(),
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
} catch (error) {
|
|
139
|
+
Logger.log(`Error in ${this.name}:`, error);
|
|
140
|
+
return data; // Return original data if processing fails
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private async fetchExternalData(email: string): Promise<any> {
|
|
145
|
+
const response = await fetch(`${this.baseUrl}/enrich`, {
|
|
146
|
+
method: "POST",
|
|
147
|
+
headers: {
|
|
148
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
149
|
+
"Content-Type": "application/json",
|
|
150
|
+
},
|
|
151
|
+
body: JSON.stringify({ email }),
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (!response.ok) {
|
|
155
|
+
throw new Error(`External API error: ${response.status}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return await response.json();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## 🧪 Plugin Testing
|
|
164
|
+
|
|
165
|
+
### Unit Testing
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// src/lib/weaviate/plugins/MyCustomPlugin.test.ts
|
|
169
|
+
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
170
|
+
import MyCustomPlugin from "./MyCustomPlugin.js";
|
|
171
|
+
|
|
172
|
+
describe("MyCustomPlugin", () => {
|
|
173
|
+
let plugin: MyCustomPlugin;
|
|
174
|
+
let mockContext: PluginContext;
|
|
175
|
+
|
|
176
|
+
beforeEach(() => {
|
|
177
|
+
plugin = new MyCustomPlugin();
|
|
178
|
+
mockContext = {
|
|
179
|
+
schemaName: "Person",
|
|
180
|
+
operation: "create",
|
|
181
|
+
metadata: {},
|
|
182
|
+
logger: {
|
|
183
|
+
log: vi.fn(),
|
|
184
|
+
error: vi.fn(),
|
|
185
|
+
warn: vi.fn(),
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("should initialize successfully", async () => {
|
|
191
|
+
await expect(plugin.initialize(mockContext)).resolves.not.toThrow();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("should process data correctly", async () => {
|
|
195
|
+
const testData = { name: "John Doe", email: "john@example.com" };
|
|
196
|
+
const result = await plugin.process(testData, mockContext);
|
|
197
|
+
|
|
198
|
+
expect(result).toHaveProperty("enrichedAt");
|
|
199
|
+
expect(result).toHaveProperty("customField");
|
|
200
|
+
expect(result.customField).toBe("processed by MyCustomPlugin");
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("should handle errors gracefully", async () => {
|
|
204
|
+
const invalidData = null;
|
|
205
|
+
const result = await plugin.process(invalidData, mockContext);
|
|
206
|
+
|
|
207
|
+
// Plugin should handle errors and return original data
|
|
208
|
+
expect(result).toBe(invalidData);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Integration Testing
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
// src/lib/weaviate/plugins/ExternalDataPlugin.test.ts
|
|
217
|
+
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
218
|
+
import ExternalDataPlugin from "./ExternalDataPlugin.js";
|
|
219
|
+
|
|
220
|
+
// Mock fetch
|
|
221
|
+
global.fetch = vi.fn();
|
|
222
|
+
|
|
223
|
+
describe("ExternalDataPlugin Integration", () => {
|
|
224
|
+
let plugin: ExternalDataPlugin;
|
|
225
|
+
let mockContext: PluginContext;
|
|
226
|
+
|
|
227
|
+
beforeEach(() => {
|
|
228
|
+
plugin = new ExternalDataPlugin();
|
|
229
|
+
mockContext = {
|
|
230
|
+
schemaName: "Person",
|
|
231
|
+
operation: "create",
|
|
232
|
+
metadata: {},
|
|
233
|
+
logger: {
|
|
234
|
+
log: vi.fn(),
|
|
235
|
+
error: vi.fn(),
|
|
236
|
+
warn: vi.fn(),
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// Set environment variables
|
|
241
|
+
process.env.EXTERNAL_API_KEY = "test-key";
|
|
242
|
+
process.env.EXTERNAL_API_URL = "https://api.example.com";
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("should fetch external data successfully", async () => {
|
|
246
|
+
const mockResponse = {
|
|
247
|
+
company: "Acme Corp",
|
|
248
|
+
industry: "Technology",
|
|
249
|
+
location: "San Francisco",
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
(fetch as any).mockResolvedValueOnce({
|
|
253
|
+
ok: true,
|
|
254
|
+
json: () => Promise.resolve(mockResponse),
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const testData = { email: "john@example.com" };
|
|
258
|
+
const result = await plugin.process(testData, mockContext);
|
|
259
|
+
|
|
260
|
+
expect(result).toHaveProperty("externalData");
|
|
261
|
+
expect(result.externalData.company).toBe("Acme Corp");
|
|
262
|
+
expect(fetch).toHaveBeenCalledWith(
|
|
263
|
+
"https://api.example.com/enrich",
|
|
264
|
+
expect.objectContaining({
|
|
265
|
+
method: "POST",
|
|
266
|
+
headers: expect.objectContaining({
|
|
267
|
+
Authorization: "Bearer test-key",
|
|
268
|
+
}),
|
|
269
|
+
}),
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## 🔧 Plugin Registration
|
|
276
|
+
|
|
277
|
+
### Manual Registration
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
// Register plugin with Weaviate instance
|
|
281
|
+
import MyCustomPlugin from "./plugins/MyCustomPlugin.js";
|
|
282
|
+
|
|
283
|
+
const weaviate = new Weaviate();
|
|
284
|
+
weaviate.registerPlugin(new MyCustomPlugin());
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Automatic Registration
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
// In your schema configuration
|
|
291
|
+
const Person: SchemaConfig = {
|
|
292
|
+
name: "Person",
|
|
293
|
+
plugins: [
|
|
294
|
+
"myCustomPlugin", // Your custom plugin
|
|
295
|
+
"externalDataPlugin", // Another custom plugin
|
|
296
|
+
],
|
|
297
|
+
// ... rest of schema
|
|
298
|
+
};
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Plugin Discovery
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
// src/lib/weaviate/plugins/index.ts
|
|
305
|
+
export { default as MyCustomPlugin } from "./MyCustomPlugin.js";
|
|
306
|
+
export { default as ExternalDataPlugin } from "./ExternalDataPlugin.js";
|
|
307
|
+
|
|
308
|
+
// Plugin registry
|
|
309
|
+
export const PLUGIN_REGISTRY = {
|
|
310
|
+
myCustomPlugin: MyCustomPlugin,
|
|
311
|
+
externalDataPlugin: ExternalDataPlugin,
|
|
312
|
+
};
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## 📊 Plugin Performance
|
|
316
|
+
|
|
317
|
+
### Caching
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
export default class CachedDataPlugin implements Plugin {
|
|
321
|
+
private cache = new Map<string, any>();
|
|
322
|
+
private cacheTimeout = 5 * 60 * 1000; // 5 minutes
|
|
323
|
+
|
|
324
|
+
async process(data: any, context: PluginContext): Promise<any> {
|
|
325
|
+
const cacheKey = this.generateCacheKey(data);
|
|
326
|
+
const cached = this.cache.get(cacheKey);
|
|
327
|
+
|
|
328
|
+
if (cached && this.isCacheValid(cached)) {
|
|
329
|
+
return { ...data, ...cached.data };
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const result = await this.fetchData(data);
|
|
333
|
+
this.cache.set(cacheKey, {
|
|
334
|
+
data: result,
|
|
335
|
+
timestamp: Date.now(),
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
return { ...data, ...result };
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private isCacheValid(cached: any): boolean {
|
|
342
|
+
return Date.now() - cached.timestamp < this.cacheTimeout;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Batch Processing
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
export default class BatchProcessingPlugin implements Plugin {
|
|
351
|
+
private batch: any[] = [];
|
|
352
|
+
private batchSize = 10;
|
|
353
|
+
private batchTimeout = 1000; // 1 second
|
|
354
|
+
|
|
355
|
+
async process(data: any, context: PluginContext): Promise<any> {
|
|
356
|
+
this.batch.push({ data, context });
|
|
357
|
+
|
|
358
|
+
if (this.batch.length >= this.batchSize) {
|
|
359
|
+
return await this.processBatch();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Set timeout for batch processing
|
|
363
|
+
setTimeout(() => this.processBatch(), this.batchTimeout);
|
|
364
|
+
|
|
365
|
+
return data; // Return original data immediately
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
private async processBatch(): Promise<void> {
|
|
369
|
+
if (this.batch.length === 0) return;
|
|
370
|
+
|
|
371
|
+
const batch = [...this.batch];
|
|
372
|
+
this.batch = [];
|
|
373
|
+
|
|
374
|
+
try {
|
|
375
|
+
const results = await this.processBatchData(batch);
|
|
376
|
+
// Apply results to original data
|
|
377
|
+
} catch (error) {
|
|
378
|
+
Logger.log("Batch processing error:", error);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## 🔍 Plugin Debugging
|
|
385
|
+
|
|
386
|
+
### Debug Logging
|
|
387
|
+
|
|
388
|
+
```typescript
|
|
389
|
+
export default class DebugPlugin implements Plugin {
|
|
390
|
+
name = "debugPlugin";
|
|
391
|
+
version = "1.0.0";
|
|
392
|
+
|
|
393
|
+
async process(data: any, context: PluginContext): Promise<any> {
|
|
394
|
+
Logger.log(`[${this.name}] Processing data:`, {
|
|
395
|
+
schemaName: context.schemaName,
|
|
396
|
+
operation: context.operation,
|
|
397
|
+
dataKeys: Object.keys(data),
|
|
398
|
+
timestamp: new Date().toISOString(),
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
const result = this.processData(data);
|
|
402
|
+
|
|
403
|
+
Logger.log(`[${this.name}] Processing complete:`, {
|
|
404
|
+
originalKeys: Object.keys(data),
|
|
405
|
+
resultKeys: Object.keys(result),
|
|
406
|
+
addedFields: Object.keys(result).filter((key) => !(key in data)),
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
return result;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Performance Monitoring
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
export default class PerformancePlugin implements Plugin {
|
|
418
|
+
name = "performancePlugin";
|
|
419
|
+
version = "1.0.0";
|
|
420
|
+
|
|
421
|
+
async process(data: any, context: PluginContext): Promise<any> {
|
|
422
|
+
const startTime = performance.now();
|
|
423
|
+
|
|
424
|
+
try {
|
|
425
|
+
const result = await this.processData(data);
|
|
426
|
+
const endTime = performance.now();
|
|
427
|
+
|
|
428
|
+
Logger.log(`[${this.name}] Processing time: ${endTime - startTime}ms`);
|
|
429
|
+
|
|
430
|
+
return result;
|
|
431
|
+
} catch (error) {
|
|
432
|
+
const endTime = performance.now();
|
|
433
|
+
Logger.log(`[${this.name}] Error after ${endTime - startTime}ms:`, error);
|
|
434
|
+
throw error;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## 🚀 Plugin Deployment
|
|
441
|
+
|
|
442
|
+
### Environment Configuration
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
# .env for plugin configuration
|
|
446
|
+
MY_PLUGIN_API_KEY=your-api-key
|
|
447
|
+
MY_PLUGIN_BASE_URL=https://api.example.com
|
|
448
|
+
MY_PLUGIN_CACHE_TTL=300000
|
|
449
|
+
MY_PLUGIN_BATCH_SIZE=10
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### Plugin Configuration
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
// src/lib/weaviate/plugins/ConfigurablePlugin.ts
|
|
456
|
+
export default class ConfigurablePlugin implements Plugin {
|
|
457
|
+
name = "configurablePlugin";
|
|
458
|
+
version = "1.0.0";
|
|
459
|
+
|
|
460
|
+
private config: PluginConfig;
|
|
461
|
+
|
|
462
|
+
async initialize(context: PluginContext): Promise<void> {
|
|
463
|
+
this.config = {
|
|
464
|
+
apiKey: process.env.MY_PLUGIN_API_KEY || "",
|
|
465
|
+
baseUrl: process.env.MY_PLUGIN_BASE_URL || "",
|
|
466
|
+
cacheTtl: parseInt(process.env.MY_PLUGIN_CACHE_TTL || "300000"),
|
|
467
|
+
batchSize: parseInt(process.env.MY_PLUGIN_BATCH_SIZE || "10"),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
interface PluginConfig {
|
|
473
|
+
apiKey: string;
|
|
474
|
+
baseUrl: string;
|
|
475
|
+
cacheTtl: number;
|
|
476
|
+
batchSize: number;
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
## 🔧 Best Practices
|
|
481
|
+
|
|
482
|
+
### 1. Error Handling
|
|
483
|
+
|
|
484
|
+
```typescript
|
|
485
|
+
async process(data: any, context: PluginContext): Promise<any> {
|
|
486
|
+
try {
|
|
487
|
+
return await this.processData(data);
|
|
488
|
+
} catch (error) {
|
|
489
|
+
Logger.log(`Plugin ${this.name} error:`, error);
|
|
490
|
+
// Return original data instead of failing
|
|
491
|
+
return data;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### 2. Resource Management
|
|
497
|
+
|
|
498
|
+
```typescript
|
|
499
|
+
async cleanup(): Promise<void> {
|
|
500
|
+
// Close connections, clear caches, etc.
|
|
501
|
+
this.cache.clear();
|
|
502
|
+
this.connection?.close();
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### 3. Plugin Dependencies
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
export default class DependentPlugin implements Plugin {
|
|
510
|
+
name = "dependentPlugin";
|
|
511
|
+
version = "1.0.0";
|
|
512
|
+
dependencies = ["personEnrichment", "externalData"];
|
|
513
|
+
|
|
514
|
+
async initialize(context: PluginContext): Promise<void> {
|
|
515
|
+
// Check if dependencies are available
|
|
516
|
+
const availablePlugins = context.metadata.availablePlugins || [];
|
|
517
|
+
const missingDeps = this.dependencies.filter((dep) => !availablePlugins.includes(dep));
|
|
518
|
+
|
|
519
|
+
if (missingDeps.length > 0) {
|
|
520
|
+
throw new Error(`Missing dependencies: ${missingDeps.join(", ")}`);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
### 4. Plugin Versioning
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
export default class VersionedPlugin implements Plugin {
|
|
530
|
+
name = "versionedPlugin";
|
|
531
|
+
version = "2.1.0";
|
|
532
|
+
|
|
533
|
+
async process(data: any, context: PluginContext): Promise<any> {
|
|
534
|
+
// Check plugin version compatibility
|
|
535
|
+
const requiredVersion = context.metadata.requiredVersion || "2.0.0";
|
|
536
|
+
if (this.compareVersions(this.version, requiredVersion) < 0) {
|
|
537
|
+
throw new Error(`Plugin version ${this.version} is too old`);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return this.processData(data);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
---
|
|
546
|
+
|
|
547
|
+
**Next Steps**: Once your plugins are developed, proceed to the [API Reference](./API_REFERENCE.md) to learn about all available methods and options.
|