diff --git a/backend/functions/lib/use-cases/orders/orders.ts b/backend/functions/lib/use-cases/orders/orders.ts index 5cd3a92956..f702f39193 100644 --- a/backend/functions/lib/use-cases/orders/orders.ts +++ b/backend/functions/lib/use-cases/orders/orders.ts @@ -64,6 +64,8 @@ export interface SyncOrdersStatus { maxTxId: string; } +export interface ImportConsolidationOptions {} + export class OrdersUseCase { private readonly casesRepo: CasesRepository; private readonly casesGateway: CasesInterface; @@ -169,12 +171,41 @@ export class OrdersUseCase { } } + public async getConsolidationPageCount( + context: ApplicationContext, + _options?: ImportConsolidationOptions, + ): Promise { + try { + //const pageCount = await this.legacyDatabaseRepo.read('', ''); + //context.logger.info(MODULE_NAME, 'Got page count for import from repo.', pageCount); + //return pageCount; + } catch (error) { + const message = 'Failed to get page count for consolidation import from repo.'; + context.logger.info(MODULE_NAME, message, error); + throw new CamsError(MODULE_NAME, { message }); + } + return 0; + } + + public async importConsolidationData( + context: ApplicationContext, + _options?: ImportConsolidationOptions, + ): Promise { + try { + //const consolidations = await this.legacyDatabaseRepo.read('', ''); + } catch (error) { + const message = 'Failed to get consolidation data from repo.'; + context.logger.info(MODULE_NAME, message, error); + throw new CamsError(MODULE_NAME, { message }); + } + return; + } + public async syncOrders( context: ApplicationContext, options?: SyncOrdersOptions, ): Promise { let initialSyncState: OrderSyncState; - try { initialSyncState = await this.runtimeStateRepo.read('ORDERS_SYNC_STATE', ''); context.logger.info( diff --git a/backend/functions/poc/activity/getPageCount.ts b/backend/functions/poc/activity/getPageCount.ts index 0a2f45a02c..202f0033ca 100644 --- a/backend/functions/poc/activity/getPageCount.ts +++ b/backend/functions/poc/activity/getPageCount.ts @@ -1,10 +1,44 @@ import { InvocationContext } from '@azure/functions'; import { PredicateAndPage } from '../model'; +import { OrdersUseCase } from '../../lib/use-cases/orders/orders'; +import { + getCasesRepository, + getCasesGateway, + getOrdersRepository, + getOrdersGateway, + getRuntimeStateRepository, + getConsolidationOrdersRepository, + getStorageGateway, +} from '../../lib/factory'; +import { OrderSyncState } from '../../lib/use-cases/gateways.types'; +import ContextCreator from '../../azure/application-context-creator'; +import { CamsError } from '../../lib/common-errors/cams-error'; -async function getPageCount(input: PredicateAndPage, context: InvocationContext) { - // Do some stuff - context.log('#################GetPageCount', JSON.stringify(input)); - return 4; +const MODULE_NAME = 'IMPORT-ACTION-GET-PAGE-COUNT'; + +async function getPageCount(input: PredicateAndPage, invocationContext: InvocationContext) { + const logger = ContextCreator.getLogger(invocationContext); + try { + const context = await ContextCreator.applicationContextCreator(invocationContext, logger); + + // Do some stuff + console.log('#################GetPageCount', JSON.stringify(input)); + // TODO: This seems silly to have to supply all of these repos and gateways. + // Are we going to add yet another for ACMS? + const orders = new OrdersUseCase( + getCasesRepository(context), + getCasesGateway(context), + getOrdersRepository(context), + getOrdersGateway(context), + getRuntimeStateRepository(context), + getConsolidationOrdersRepository(context), + getStorageGateway(context), + ); + + return orders.getConsolidationPageCount(context, {}); + } catch (originalError) { + throw new CamsError(MODULE_NAME, { originalError }); + } } export default { diff --git a/user-interface/package-lock.json b/user-interface/package-lock.json index 747913d21d..c7f3bb5fd3 100644 --- a/user-interface/package-lock.json +++ b/user-interface/package-lock.json @@ -30,6 +30,7 @@ }, "devDependencies": { "@faker-js/faker": "^9.2.0", + "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.14",