@flatfile/plugin-record-hook
Advanced tools
Comparing version 0.1.4 to 0.1.5
# @flatfile/plugin-record-hook | ||
## 0.1.5 | ||
### Patch Changes | ||
- c2310c0: Add event to RecordHook Handler | ||
## 0.1.4 | ||
@@ -4,0 +10,0 @@ |
import { FlatfileEvent, FlatfileListener } from '@flatfile/listener'; | ||
import { FlatfileRecord } from '@flatfile/hooks'; | ||
declare const RecordHook: (event: FlatfileEvent, handler: (record: FlatfileRecord) => any | Promise<any>) => Promise<((record: FlatfileRecord) => any | Promise<any>) | undefined>; | ||
declare const RecordHook: (event: FlatfileEvent, handler: (record: FlatfileRecord, event: FlatfileEvent) => any | Promise<any>) => Promise<((record: FlatfileRecord, event: FlatfileEvent) => any | Promise<any>) | undefined>; | ||
@@ -6,0 +6,0 @@ declare const recordHook: (sheetSlug: string, callback: (record: FlatfileRecord) => {}) => (client: FlatfileListener) => void; |
@@ -122,3 +122,3 @@ "use strict"; | ||
for (const x of batch.records) { | ||
await handler(x); | ||
await handler(x, event); | ||
} | ||
@@ -125,0 +125,0 @@ const recordsUpdates = new RecordTranslater( |
{ | ||
"name": "@flatfile/plugin-record-hook", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "A plugin for writing custom record-level hooks in Flatfile.", | ||
@@ -5,0 +5,0 @@ "registryMetadata": { |
import { FlatfileEvent } from '@flatfile/listener' | ||
import { FlatfileRecord, FlatfileRecords } from '@flatfile/hooks' | ||
import { RecordWithLinks, Record_, RecordsWithLinks, Records } from '@flatfile/api/api' | ||
import { Record_, Records } from '@flatfile/api/api' | ||
import { RecordTranslater } from './record.translater' | ||
@@ -9,7 +9,7 @@ import api from '@flatfile/api' | ||
event: FlatfileEvent, | ||
handler: (record: FlatfileRecord) => any | Promise<any> | ||
handler: (record: FlatfileRecord, event: FlatfileEvent) => any | Promise<any> | ||
) => { | ||
const { sheetId } = event.context | ||
try { | ||
const records = await event.cache.init<RecordsWithLinks>( | ||
const records = await event.cache.init<Records>( | ||
'records', | ||
@@ -24,3 +24,3 @@ async () => (await event.data).records | ||
for (const x of batch.records) { | ||
await handler(x) | ||
await handler(x, event) | ||
} | ||
@@ -36,3 +36,3 @@ | ||
event.afterAll(async () => { | ||
const records = event.cache.get<RecordsWithLinks>('records') | ||
const records = event.cache.get<Records>('records') | ||
try { | ||
@@ -52,3 +52,3 @@ return await api.records.update(sheetId, records) | ||
const prepareXRecords = async (records: any): Promise<FlatfileRecords<any>> => { | ||
const clearedMessages: RecordWithLinks[] = records.map( | ||
const clearedMessages: Record_[] = records.map( | ||
(record: { values: { [x: string]: { messages: never[] } } }) => { | ||
@@ -62,4 +62,4 @@ // clear existing cell validation messages | ||
) | ||
const fromX = new RecordTranslater<RecordWithLinks>(clearedMessages) | ||
const fromX = new RecordTranslater<Record_>(clearedMessages) | ||
return fromX.toFlatFileRecords() | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20832