import { client } from './client'; import { TYPE } from './constants'; export async function allRecordsForProject(projectId: string): Promise { const allMerchants = await client.items.all({ 'filter[type]': TYPE.merchant }); const merchant = allMerchants.find((item: any) => { return item.projectId === projectId; }); if (!merchant) { console.error('Couldnt find merchant for projectId', projectId); return null; } const allRecords = await client.items.all({ 'page[limit]': 10000 }); const merchantRecords = allRecords.filter((item: any) => { return item.merchant && item.merchant === merchant.id; }); merchantRecords.push(merchant); return merchantRecords; } exports.allRecordsForProject = allRecordsForProject;