summaryrefslogtreecommitdiff
path: root/lib/approval/handlers-registry.ts
blob: 1e8140e52a94b5442eab364dbb5f76aa42e2fbac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
 * 결재 액션 핸들러 중앙 등록소
 * 
 * 모든 결재 가능한 액션의 핸들러를 한 곳에서 등록
 * instrumentation.ts 또는 Next.js middleware에서 import하여 초기화
 */

import { registerActionHandler } from './approval-workflow';

/**
 * 모든 핸들러를 등록하는 초기화 함수
 * 앱 시작 시 한 번만 호출
 */
export async function initializeApprovalHandlers() {
  console.log('[Approval Handlers] Registering all handlers...');

  // 1. PQ 실사 관련 핸들러
  const { 
    requestPQInvestigationInternal,
    reRequestPQInvestigationInternal
  } = await import('@/lib/vendor-investigation/handlers');
  
  // PQ 실사의뢰 핸들러 등록
  registerActionHandler('pq_investigation_request', requestPQInvestigationInternal);
  
  // PQ 실사 재의뢰 핸들러 등록
  registerActionHandler('pq_investigation_rerequest', reRequestPQInvestigationInternal);

  // 2. 발주 요청 핸들러
  // const { createPurchaseOrderInternal } = await import('@/lib/purchase-order/handlers');
  // registerActionHandler('purchase_order_request', createPurchaseOrderInternal);

  // 3. 계약 승인 핸들러
  // const { approveContractInternal } = await import('@/lib/contract/handlers');
  // registerActionHandler('contract_approval', approveContractInternal);

  // ... 추가 핸들러 등록

  console.log('[Approval Handlers] All handlers registered successfully');
}

/**
 * 등록된 모든 핸들러 목록 조회 (디버깅용)
 */
export async function listRegisteredHandlers() {
  const { getRegisteredHandlers } = await import('./approval-workflow');
  return await getRegisteredHandlers();
}