Skip to content

Commit

Permalink
fix: tick() params (#306)
Browse files Browse the repository at this point in the history
* fix: require tick() params

* fix: all params optional

* Update small-moles-judge.md

* Update small-moles-judge.md

* fix: require progress, empty string message if not provided

* fix: don't include undefined properties
  • Loading branch information
carlbrugger authored Nov 8, 2023
1 parent 2dfe659 commit edaedf5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .changeset/small-moles-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@flatfile/plugin-connect-via-merge': patch
'@flatfile/plugin-space-configure': patch
'@flatfile/plugin-job-handler': patch
'@flatfile/util-extractor': patch
---

Fix tick params
6 changes: 3 additions & 3 deletions plugins/job-handler/src/job.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function jobHandler(
job: string,
handler: (
event: FlatfileEvent,
tick: (progress?: number, message?: string) => Promise<Flatfile.JobResponse>
tick: (progress: number, message?: string) => Promise<Flatfile.JobResponse>
) => Promise<void | Flatfile.JobCompleteDetails>,
opts: PluginOptions = {}
) {
Expand All @@ -42,10 +42,10 @@ export function jobHandler(
progress: 10,
})

const tick = async (progress: number, info: string) => {
const tick = async (progress: number, info?: string) => {
return await api.jobs.ack(jobId, {
info,
progress,
...(info !== undefined && { info }),
})
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/merge-connection/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function mergePlugin() {
function handleCreateConnectedWorkbooks() {
return async (
event: FlatfileEvent,
tick: (progress?: number, message?: string) => Promise<Flatfile.JobResponse>
tick: (progress: number, message?: string) => Promise<Flatfile.JobResponse>
) => {
try {
const { spaceId, environmentId, jobId } = event.context
Expand Down Expand Up @@ -191,7 +191,7 @@ function handleCreateConnectedWorkbooks() {
function handleConnectedWorkbookSync() {
return async (
event: FlatfileEvent,
tick: (progress?: number, message?: string) => Promise<Flatfile.JobResponse>
tick: (progress: number, message?: string) => Promise<Flatfile.JobResponse>
) => {
try {
const { spaceId, workbookId, environmentId } = event.context
Expand Down Expand Up @@ -296,7 +296,7 @@ async function checkAllSyncsComplete(
async function waitForMergeSync(
mergeClient: MergeClient,
category: string,
tick: (progress?: number, message?: string) => Promise<Flatfile.JobResponse>
tick: (progress: number, message?: string) => Promise<Flatfile.JobResponse>
): Promise<void> {
try {
let attempts = 0
Expand Down
2 changes: 1 addition & 1 deletion plugins/space-configure/src/space.configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function configureSpace(
callback?: (
event: FlatfileEvent,
workbookIds: string[],
tick: (progress?: number, message?: string) => Promise<Flatfile.JobResponse>
tick: (progress: number, message?: string) => Promise<Flatfile.JobResponse>
) => any | Promise<any>
) {
return function (listener: FlatfileListener) {
Expand Down
2 changes: 1 addition & 1 deletion utils/extractor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Extractor = (
const buffer = await getFileBuffer(event)
const { jobId } = event.context
try {
const tick = async (progress: number, info: string) => {
const tick = async (progress: number, info?: string) => {
await api.jobs.ack(jobId, { progress, info })
if (debug) {
console.log(`Job progress: ${progress}, Info: ${info}`)
Expand Down

0 comments on commit edaedf5

Please sign in to comment.