Provider
Source: src/data/provider/
Service
createProviderService / ProviderService
Factory: createProviderService(repo: ProviderRepository) — returns ProviderService.
| Method | Parameters | Returns | Description |
|---|---|---|---|
| createOrActivateProvider | (ctx: RequestContext, input: { type: string, tenantId?: string, isActive?: boolean, config?: Record<string, unknown> }) | Promise<ProviderRecord> | Creates a new provider or re-activates an existing one by type; upserts config |
| getActiveProviderByType | (ctx: RequestContext, type: string, tenantId?: string) | Promise<ProviderRecord | null> | Returns the active provider for a type; falls back to global (no tenant) if no tenant-scoped match |
| deactivateProvider | (ctx: RequestContext, id: string) | Promise<ProviderRecord> | Marks a provider as inactive |
Repository
ProviderRepository
| Method | Parameters | Returns |
|---|---|---|
| getById | (ctx: RequestContext, id: string) | Promise<ProviderRecord | null> |
| listByTenant | (ctx: RequestContext) | Promise<ProviderRecord[]> |
| listGlobal | () | Promise<ProviderRecord[]> |
| findByType | (type: string, tenantId?: string) | Promise<ProviderRecord[]> |
| create | (ctx: RequestContext, input: ProviderCreateInput) | Promise<ProviderRecord> |
| update | (ctx: RequestContext, id: string, patch: Partial<ProviderCreateInput>) | Promise<ProviderRecord> |
ProviderRecord
| Field | Type |
|---|---|
| id | string |
| type | string |
| tenantId | string (optional) |
| isActive | boolean |
| config | Record<string, unknown> |
| createdAt | Date |
| updatedAt | Date |
Validators
providerSchema
| Field | Type | Required | Default |
|---|---|---|---|
| type | string | Yes | — |
| tenantId | string | No | — |
| isActive | boolean | No | true |
| config | Record<string, unknown> | No | {} |
Inferred Types
Provider—z.infer<typeof providerSchema>