From 10d589c6f6fda966b2642b22d4284c0764b06688 Mon Sep 17 00:00:00 2001 From: "Alex Rock (Koala)" Date: Thu, 3 Oct 2024 19:23:44 -0600 Subject: [PATCH] koala: initial commit --- package.json | 2 +- validate/PDFReportGenerator/src/index.ts | 23 ++++++----------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 120618cd7..e2675582e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "plugins/*", "support/*", "utils/*", - "validators/*" + "validate/*" ], "scripts": { "clean": "find ./ '(' -name 'node_modules' -o -name 'dist' -o -name '.turbo' -o -name '.parcel-cache' ')' -type d -exec rm -rf {} +", diff --git a/validate/PDFReportGenerator/src/index.ts b/validate/PDFReportGenerator/src/index.ts index 1e2b0d5a6..9b00873d3 100644 --- a/validate/PDFReportGenerator/src/index.ts +++ b/validate/PDFReportGenerator/src/index.ts @@ -41,22 +41,11 @@ const defaultStyle: ReportStyle = { } export default function (listener: FlatfileListener) { - listener.use( - recordHook('contacts', async (record) => { - const email = record.get('email') as string - - const validEmailAddress = /^[^\s@]+@[^\s@]+\.[^\s@]+$/ - if (!email || !validEmailAddress.test(email)) { - record.addError('email', 'Invalid email address') - } - - return record - }) - ) - - listener.on('action:custom', async (event: FlatfileEvent) => { - const { action, context } = event - if (action.operation === 'generate_pdf') { + listener.on( + 'job:ready', + { job: `sheet:generate_pdf` }, + async (event: FlatfileEvent) => { + const { action, context } = event try { const userStyle: Partial = action.payload?.style || {} const style: ReportStyle = { ...defaultStyle, ...userStyle } @@ -194,5 +183,5 @@ export default function (listener: FlatfileListener) { await event.reply('Error generating or uploading PDF') } } - }) + ) }