Remove Temporal workflow from KYC service
All checks were successful
Build Docker Image / build (push) Successful in 2m22s

This commit is contained in:
Ruslan Bakiev
2026-05-31 12:15:58 +05:00
parent 6b23e6b60c
commit f7f5559372
4 changed files with 4 additions and 456 deletions

View File

@@ -1,6 +1,5 @@
import { GraphQLError } from 'graphql'
import { prisma } from '../db.js'
import { startKycWorkflow } from '../services/temporal.js'
import type { AuthContext } from '../auth.js'
export const userTypeDefs = `#graphql
@@ -123,43 +122,10 @@ async function createApplicationRussia(_: unknown, args: { input: RussiaInput },
contactEmail: args.input.contactEmail,
contactPhone: args.input.contactPhone,
objectId: details.id,
workflowStatus: 'pending_review',
},
})
// Start Temporal workflow
try {
await startKycWorkflow({
kyc_request_id: app.uuid,
team_name: app.teamName || args.input.companyName,
owner_id: ctx.userId,
owner_email: args.input.contactEmail,
country_code: 'RU',
country_data: {
company_name: details.companyName,
company_full_name: details.companyFullName,
inn: details.inn,
kpp: details.kpp,
ogrn: details.ogrn,
address: details.address,
bank_name: details.bankName,
bik: details.bik,
correspondent_account: details.correspondentAccount,
},
})
await prisma.kYCApplication.update({
where: { id: app.id },
data: { workflowStatus: 'active' },
})
} catch (e) {
console.error('Failed to start KYC workflow:', e)
await prisma.kYCApplication.update({
where: { id: app.id },
data: { workflowStatus: 'error' },
})
}
const updated = await prisma.kYCApplication.findUnique({ where: { id: app.id } })
return { kycApplication: updated, success: true }
return { kycApplication: app, success: true }
}
export const userResolvers = {

View File

@@ -1,28 +0,0 @@
import { Client, Connection } from '@temporalio/client'
const TEMPORAL_HOST = process.env.TEMPORAL_HOST || 'temporal:7233'
const TEMPORAL_NAMESPACE = process.env.TEMPORAL_NAMESPACE || 'default'
const TEMPORAL_TASK_QUEUE = process.env.TEMPORAL_TASK_QUEUE || 'kyc-task-queue'
interface KycWorkflowData {
kyc_request_id: string
team_name: string
owner_id: string
owner_email: string
country_code: string
country_data: Record<string, string>
}
export async function startKycWorkflow(data: KycWorkflowData): Promise<string> {
const connection = await Connection.connect({ address: TEMPORAL_HOST })
const client = new Client({ connection, namespace: TEMPORAL_NAMESPACE })
const handle = await client.workflow.start('kyc_application', {
args: [data],
taskQueue: TEMPORAL_TASK_QUEUE,
workflowId: data.kyc_request_id,
})
console.log(`KYC workflow started: ${handle.workflowId}`)
return handle.workflowId
}