Skip to content

Latest commit

 

History

History
529 lines (313 loc) · 22.2 KB

CHANGELOG.md

File metadata and controls

529 lines (313 loc) · 22.2 KB

@defer/client

2.3.0

Minor Changes

2.2.1

Patch Changes

2.2.0

Minor Changes

2.1.1

Patch Changes

2.1.0

Minor Changes

2.0.0

Major Changes

  • #116 2276048 Thanks @gearnode! - This new major version brings scheduling features to the local developer experience.

    Features:

    • concurrency
    • delay
    • reschedule
    • cancel
    • discard
    • DeferError has been replaced with respective errors for each client method.

    Breaking changes:

    • getExecution does not return the result anymore. To do so, one must use getExecutionResult.

Minor Changes

1.15.0

Minor Changes

1.14.1

Patch Changes

1.14.0

Minor Changes

1.13.1

Patch Changes

1.13.0

Minor Changes

  • #102 5613d53 Thanks @charlypoly! - Add assignOptions() helper

    assignOptions is helpful to change the behavior of a given Background Function by combining multiple options such as delay, metadata or discardAfter:

    import { assignOptions, delay } from "@defer/client";
    import handleStripeWebhookFn from "./defer/handleStripeWebhook.js";
    
    // ...
    
    const handleStripeWebhook = assignOptions(handleStripeWebhookFn, {
      discardAfter: '12h'
      // process webhooks in the right order
      delay: event.created + 60 * 10,
      // add metadata for the the Defer Console
      metadata: {
        livemode: event.livemode,
        type: event.type,
        apiVersion: event.api_version,
      },
    });
    
    handleStripeWebhook(event.id)
      .then((executionID) => {
        response.sendStatus(
          200,
          "application/json",
          JSON.stringify({ executionID })
        );
      })
      .catch((err) => {
        response.sendStatus(400);
      });
    
    // ...

1.12.1

Minor Changes

Patch Changes

  • #100 4e367da Thanks @estubmo! - Bun support: Use crypto rather than URL/Blob API for generating random UUID

1.11.0

Minor Changes

1.10.0

Minor Changes

1.9.0

Minor Changes

Patch Changes

1.8.1

Patch Changes

1.8.0

Minor Changes

  • #80 27a1d46 Thanks @gearnode! - Add cancel execution:

    import { cancelExecution } from "@defer/client";
    
    // ...
    
    const { id } = await cancelExecution(executionId);
    
    // ...

1.7.2

Patch Changes

1.7.1

Patch Changes

1.7.0

Minor Changes

  • #66 b9973d5 Thanks @charlypoly! - Introducing @defer/client/next integration

    This release introduces two new helpers that makes Defer deeply integrated with NextJS:

    • asNextRoute(): used in combination of useDeferRoute() to trigger background functions from Client-side Components
    • useDeferRoute(): trigger and wait for the result of a background functions from Client-side Components

    Next API Routes

    import { asNextRoute } from "@defer/client/next";
    import createThumbnails from "../../defer/createThumbnails";
    
    const { GetHandler, PostHandler } = asNextRoute(createThumbnails);
    
    export const GET = GetHandler;
    export const POST = PostHandler;

    React client-side component

    import { useDeferRoute } from "@defer/client/next";
    import createThumbnails from "../../defer/createThumbnails";
    
    export function MyComp() {
      const { request, loading, result } = useDeferRoute(createThumbnails);
      return (
        <div>
          <span>Loading: {loading ? "Yes" : "No"}</span>
          <span>Result: {result ? JSON.stringify(result) : "--"}</span>
          <button onClick={() => request("")}>Call</button>
        </div>
      );
    }

1.6.0

Minor Changes

  • #70 4646cd0 Thanks @gearnode! - Introducing maxDuration support

    defer() exposes a new maxDuration configuration:

    const importContacts = (companyId: string, contacts: Contact[]) => {
      //  ...
    };
    
    export default defer(importContacts, {
      maxDuration: 10, // timeout after 10secs
    });

    BREAKING CHANGE: maxDuration has a default value to 30min. Users having executions going over this limit can override it with a higher value { maxDuration: 3600 }

Patch Changes

1.5.0

Minor Changes

1.4.0

Minor Changes

1.3.1

Patch Changes

1.3.0

Minor Changes

1.2.0

Minor Changes

Patch Changes

1.1.0

Minor Changes

  • #36 ccc39dd Thanks @charlypoly! - expose getExecution(id) to poll for an execution status and result:

    import { type FetchExecutionResponse, getExecution } from "@defer/client";
    import type { NextApiRequest, NextApiResponse } from "next";
    
    type Response = {
      res: FetchExecutionResponse;
    };
    
    export default async function handler(
      req: NextApiRequest,
      res: NextApiResponse<Response>,
    ) {
      const executionId = req.query.id;
      const ret = await getExecution(executionId as string);
      res.status(200).json({ res: ret });
    }

1.0.0

Major Changes

  • #29 859bf46 Thanks @gearnode! - Add concurrency limit option.

    import { defer } from "@defer/client";
    
    async function oneByOne() {
      // do something...
    }
    
    export default defer(oneByOne, { concurrency: 1 });
  • #34 fe251f2 Thanks @charlypoly! - BREAKING CHANGE:

    • Renamed defer.schedule() to defer.cron()
    • defer.cron() no longer takes a english string but a CRON tab string
    import { defer } from "@defer.run/client";
    
    const weeklyBrief = async () => {
      // ...
    };
    
    export default defer.cron(weeklyBrief, "5 0 * * *");

Minor Changes

  • #34 e399d75 Thanks @charlypoly! - Deprecate defer.await() in favor of awaitResult(deferFn)

    import { importContacts } from "../defer/importContacts";
    
    const importContactWithResult = awaitResult(importContacts);
    const result = await importContactWithResult("1", []);

0.5.0

Minor Changes

  • #26 4d2c4d4 Thanks @gearnode! - Add a primary retry option when defining defer function.

    import { defer } from "@defer/client";
    
    async function makeAPICallWhoMaybeFail() {
      // do something...
    }
    
    export default defer(makeAPICallWhoMaybeFail, { retry: 5 });

0.4.0

Minor Changes

  • #24 ca35544 Thanks @charlypoly! - Introduce a new API to delay an execution:

    import { delay } from "@defer/client";
    import { helloWorld } from "../defer/helloWorld";
    
    // create a delayed execution
    const delayedHelloWorld = delay(helloWorld, "1h");
    
    delayedHelloWorld(); // background execution in 1 hour

0.3.0

Minor Changes

  • #20 99ed4df Thanks @charlypoly! - Introduce defer.schedule(fn, frequencyStr)

    Defer now support scheduled functions (CRON), as follows:

    import { defer } from "@defer/client";
    
    async function myDeferWorkflow() {
      const users = await prisma.user.find({
        where: {
          // ...
        },
      });
    
      // do something...
    }
    
    export default defer.cron(myDeferWorkflow, "every day at 10am");

    Notes

    • a scheduled function should not take arguments
    • a scheduled function is scheduled on UTC time
    • a scheduled function should not be invoked (will result in errors)

0.2.3

Patch Changes

0.2.2

Patch Changes

0.2.1

Patch Changes

0.2.0

Minor Changes

Patch Changes

0.1.0

Minor Changes

Patch Changes

0.0.16

Patch Changes

0.0.7

Patch Changes

  • support multiple arguments + error handling

0.0.6

Patch Changes

  • ESM fix

0.0.5

Patch Changes

  • major bugfix

0.0.4

Patch Changes

  • fetch

0.0.4-next.0

Patch Changes

  • debug mode

0.0.2

Patch Changes

  • fix for fetch client (POST)