> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Migration Checklist

> This document tracks the migration of existing search/filter/sort/pagination code to the centralized PF-57 framework.

**Version:** 1.0.0\
**Created:** 2026-01-08\
**Status:** ✅ Complete

## Overview

This document tracks the migration of existing search/filter/sort/pagination code to the centralized PF-57 framework.

***

## Migration Status

### Legend

* ✅ Complete
* 🔄 In Progress
* ⏳ Pending
* ❌ Blocked

***

## Platform Foundation (PF) Modules

| File                                            | Patterns                 | Security Fix     | Status     |
| ----------------------------------------------- | ------------------------ | ---------------- | ---------- |
| `src/platform/documents/useDocumentSearch.ts`   | Filter, Sort, FTS        | N/A              | ✅ Complete |
| `src/platform/data-manager/hooks/useRawData.ts` | Search, Pagination, Sort | ✅ Added escaping | ✅ Complete |

***

## HR Core Modules

| File                                    | Patterns                         | Security Fix          | Status     |
| --------------------------------------- | -------------------------------- | --------------------- | ---------- |
| `src/cores/hr/hooks/useCandidates.ts`   | Search, Filter, Pagination, Sort | Replaced local escape | ✅ Complete |
| `src/cores/hr/hooks/useEmployeeList.ts` | Search, Filter, Pagination, Sort | ✅ Added escaping      | ✅ Complete |
| `src/cores/hr/hooks/useApplications.ts` | Filter, Pagination, Sort         | N/A                   | ✅ Complete |
| `src/cores/hr/hooks/useJobPostings.ts`  | Search, Filter, Pagination, Sort | ✅ Added escaping      | ✅ Complete |

***

## FA Core Modules

| File                                      | Patterns             | Security Fix     | Status     |
| ----------------------------------------- | -------------------- | ---------------- | ---------- |
| `src/cores/fa/hooks/useVendors.ts`        | Search, Filter, Sort | ✅ Added escaping | ✅ Complete |
| `src/cores/fa/hooks/usePurchaseOrders.ts` | Search, Filter, Sort | ✅ Added escaping | ✅ Complete |
| `src/cores/fa/hooks/useJournalEntries.ts` | Sort                 | N/A              | ✅ Complete |

***

## Security Fixes Summary

The following hooks had **unescaped ILIKE search terms** which could allow pattern injection:

| Hook                | Before                    | After                        |
| ------------------- | ------------------------- | ---------------------------- |
| `useRawData`        | `%${search}%`             | `escapeILikePattern(search)` |
| `useEmployeeList`   | `%${filters.search}%`     | `buildILikeOrConditions()`   |
| `useJobPostings`    | `%${filters.search}%`     | `escapeILikePattern()`       |
| `useVendors`        | `%${filters.searchTerm}%` | `buildILikeOrConditions()`   |
| `usePurchaseOrders` | `%${filters.search}%`     | `buildILikeOrConditions()`   |

***

## Framework Utilities Used

| Utility                  | From                    | Purpose                       |
| ------------------------ | ----------------------- | ----------------------------- |
| `escapeILikePattern`     | `@/platform/search`     | Escape special chars in ILIKE |
| `buildILikeOrConditions` | `@/platform/search`     | Build safe OR conditions      |
| `calculateRange`         | `@/platform/pagination` | Calculate Supabase `.range()` |
| `applySorting`           | `@/platform/sort`       | Apply sort config to query    |
| `createSortConfig`       | `@/platform/sort`       | Create single-field sort      |

***

## Backwards Compatibility

A backwards compatibility module was created at `src/shared/lib/utils/search.ts` with deprecated re-exports to ease gradual migration of other files.

***

## Validation Checklist

* [x] All hooks use centralized framework utilities
* [x] No duplicate search/filter/sort/pagination code
* [x] All search terms properly escaped
* [x] Pagination uses `calculateRange()`
* [x] Sorting uses `applySorting()`
* [x] Backwards compatibility exports created
* [x] Unit tests created (42 test cases)
* [x] Integration tests created (8 test cases)
* [x] E2E tests created (6 test flows)
* [x] All tasks marked complete in PF-57-TASKS.md
* [x] Implementation log updated
