Skip to main content

Provider

Source: src/data/provider/

Service​

createProviderService / ProviderService​

Factory: createProviderService(repo: ProviderRepository) — returns ProviderService.

MethodParametersReturnsDescription
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​

MethodParametersReturns
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​

FieldType
idstring
typestring
tenantIdstring (optional)
isActiveboolean
configRecord<string, unknown>
createdAtDate
updatedAtDate

Validators​

providerSchema​

FieldTypeRequiredDefault
typestringYes—
tenantIdstringNo—
isActivebooleanNotrue
configRecord<string, unknown>No{}

Inferred Types​

  • Provider — z.infer<typeof providerSchema>