diff --git a/.changeset/perfect-onions-call.md b/.changeset/perfect-onions-call.md deleted file mode 100644 index b6d982f754..0000000000 --- a/.changeset/perfect-onions-call.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -"@trigger.dev/sdk": patch -"trigger.dev": patch -"@trigger.dev/core": patch ---- - -Added new batch.trigger and batch.triggerByTask methods that allows triggering multiple different tasks in a single batch: - -```ts -import { batch } from '@trigger.dev/sdk/v3'; -import type { myTask1, myTask2 } from './trigger/tasks'; - -// Somewhere in your backend code -const response = await batch.trigger([ - { id: 'task1', payload: { foo: 'bar' } }, - { id: 'task2', payload: { baz: 'qux' } }, -]); - -for (const run of response.runs) { - if (run.ok) { - console.log(run.output); - } else { - console.error(run.error); - } -} -``` - -Or if you are inside of a task, you can use `triggerByTask`: - -```ts -import { batch, task, runs } from '@trigger.dev/sdk/v3'; - -export const myParentTask = task({ - id: 'myParentTask', - run: async () => { - const response = await batch.triggerByTask([ - { task: myTask1, payload: { foo: 'bar' } }, - { task: myTask2, payload: { baz: 'qux' } }, - ]); - - const run1 = await runs.retrieve(response.runs[0]); - console.log(run1.output) // typed as { foo: string } - - const run2 = await runs.retrieve(response.runs[1]); - console.log(run2.output) // typed as { baz: string } - - const response2 = await batch.triggerByTaskAndWait([ - { task: myTask1, payload: { foo: 'bar' } }, - { task: myTask2, payload: { baz: 'qux' } }, - ]); - - if (response2.runs[0].ok) { - console.log(response2.runs[0].output) // typed as { foo: string } - } - - if (response2.runs[1].ok) { - console.log(response2.runs[1].output) // typed as { baz: string } - } - } -}); - -export const myTask1 = task({ - id: 'myTask1', - run: async () => { - return { - foo: 'bar' - } - } -}); - -export const myTask2 = task({ - id: 'myTask2', - run: async () => { - return { - baz: 'qux' - } - } -}); - -``` diff --git a/.changeset/ten-pans-itch.md b/.changeset/ten-pans-itch.md deleted file mode 100644 index 4538c457a9..0000000000 --- a/.changeset/ten-pans-itch.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -"@trigger.dev/react-hooks": minor -"@trigger.dev/sdk": minor -"@trigger.dev/core": minor ---- - -Improved Batch Triggering: - -- The new Batch Trigger endpoint is now asynchronous and supports up to 500 runs per request. -- The new endpoint also supports triggering multiple different tasks in a single batch request (support in the SDK coming soon). -- The existing `batchTrigger` method now supports the new endpoint, and shouldn't require any changes to your code. - -- Idempotency keys now expire after 24 hours, and you can customize the expiration time when creating a new key by using the `idempotencyKeyTTL` parameter: - -```ts -await myTask.batchTrigger([{ payload: { foo: "bar" }}], { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" }) -// Works for individual items as well: -await myTask.batchTrigger([{ payload: { foo: "bar" }, options: { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" }}]) -// And `trigger`: -await myTask.trigger({ foo: "bar" }, { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" }); -``` - -### Breaking Changes - -- We've removed the `idempotencyKey` option from `triggerAndWait` and `batchTriggerAndWait`, because it can lead to permanently frozen runs in deployed tasks. We're working on upgrading our entire system to support idempotency keys on these methods, and we'll re-add the option once that's complete. diff --git a/.changeset/wild-needles-hunt.md b/.changeset/wild-needles-hunt.md deleted file mode 100644 index 38988f2089..0000000000 --- a/.changeset/wild-needles-hunt.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@trigger.dev/react-hooks": patch -"@trigger.dev/sdk": patch -"@trigger.dev/core": patch ---- - -Added ability to subscribe to a batch of runs using runs.subscribeToBatch diff --git a/packages/build/CHANGELOG.md b/packages/build/CHANGELOG.md index ddb795ed16..28b7da9114 100644 --- a/packages/build/CHANGELOG.md +++ b/packages/build/CHANGELOG.md @@ -1,5 +1,12 @@ # @trigger.dev/build +## 3.3.0 + +### Patch Changes + +- Updated dependencies: + - `@trigger.dev/core@3.3.0` + ## 3.2.2 ### Patch Changes diff --git a/packages/build/package.json b/packages/build/package.json index fc3c835a04..f5a8db3731 100644 --- a/packages/build/package.json +++ b/packages/build/package.json @@ -1,6 +1,6 @@ { "name": "@trigger.dev/build", - "version": "3.2.2", + "version": "3.3.0", "description": "trigger.dev build extensions", "license": "MIT", "publishConfig": { @@ -65,7 +65,7 @@ "check-exports": "attw --pack ." }, "dependencies": { - "@trigger.dev/core": "workspace:3.2.2", + "@trigger.dev/core": "workspace:3.3.0", "pkg-types": "^1.1.3", "tinyglobby": "^0.2.2", "tsconfck": "3.1.3" diff --git a/packages/cli-v3/CHANGELOG.md b/packages/cli-v3/CHANGELOG.md index f3cb6f8340..3033aec8a8 100644 --- a/packages/cli-v3/CHANGELOG.md +++ b/packages/cli-v3/CHANGELOG.md @@ -1,5 +1,87 @@ # trigger.dev +## 3.3.0 + +### Patch Changes + +- Added new batch.trigger and batch.triggerByTask methods that allows triggering multiple different tasks in a single batch: ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) + + ```ts + import { batch } from "@trigger.dev/sdk/v3"; + import type { myTask1, myTask2 } from "./trigger/tasks"; + + // Somewhere in your backend code + const response = await batch.trigger([ + { id: "task1", payload: { foo: "bar" } }, + { id: "task2", payload: { baz: "qux" } }, + ]); + + for (const run of response.runs) { + if (run.ok) { + console.log(run.output); + } else { + console.error(run.error); + } + } + ``` + + Or if you are inside of a task, you can use `triggerByTask`: + + ```ts + import { batch, task, runs } from "@trigger.dev/sdk/v3"; + + export const myParentTask = task({ + id: "myParentTask", + run: async () => { + const response = await batch.triggerByTask([ + { task: myTask1, payload: { foo: "bar" } }, + { task: myTask2, payload: { baz: "qux" } }, + ]); + + const run1 = await runs.retrieve(response.runs[0]); + console.log(run1.output); // typed as { foo: string } + + const run2 = await runs.retrieve(response.runs[1]); + console.log(run2.output); // typed as { baz: string } + + const response2 = await batch.triggerByTaskAndWait([ + { task: myTask1, payload: { foo: "bar" } }, + { task: myTask2, payload: { baz: "qux" } }, + ]); + + if (response2.runs[0].ok) { + console.log(response2.runs[0].output); // typed as { foo: string } + } + + if (response2.runs[1].ok) { + console.log(response2.runs[1].output); // typed as { baz: string } + } + }, + }); + + export const myTask1 = task({ + id: "myTask1", + run: async () => { + return { + foo: "bar", + }; + }, + }); + + export const myTask2 = task({ + id: "myTask2", + run: async () => { + return { + baz: "qux", + }; + }, + }); + ``` + +- Updated dependencies: + - `@trigger.dev/core@3.3.0` + - `@trigger.dev/build@3.3.0` + ## 3.2.2 ### Patch Changes diff --git a/packages/cli-v3/package.json b/packages/cli-v3/package.json index 3fbbbabf84..ecc1fd790c 100644 --- a/packages/cli-v3/package.json +++ b/packages/cli-v3/package.json @@ -1,6 +1,6 @@ { "name": "trigger.dev", - "version": "3.2.2", + "version": "3.3.0", "description": "A Command-Line Interface for Trigger.dev (v3) projects", "type": "module", "license": "MIT", @@ -87,8 +87,8 @@ "@opentelemetry/sdk-trace-base": "1.25.1", "@opentelemetry/sdk-trace-node": "1.25.1", "@opentelemetry/semantic-conventions": "1.25.1", - "@trigger.dev/build": "workspace:3.2.2", - "@trigger.dev/core": "workspace:3.2.2", + "@trigger.dev/build": "workspace:3.3.0", + "@trigger.dev/core": "workspace:3.3.0", "c12": "^1.11.1", "chalk": "^5.2.0", "cli-table3": "^0.6.3", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 8aee41777e..f2b8b82e20 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,112 @@ # internal-platform +## 3.3.0 + +### Minor Changes + +- Improved Batch Triggering: ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) + + - The new Batch Trigger endpoint is now asynchronous and supports up to 500 runs per request. + - The new endpoint also supports triggering multiple different tasks in a single batch request (support in the SDK coming soon). + - The existing `batchTrigger` method now supports the new endpoint, and shouldn't require any changes to your code. + + - Idempotency keys now expire after 24 hours, and you can customize the expiration time when creating a new key by using the `idempotencyKeyTTL` parameter: + + ```ts + await myTask.batchTrigger([{ payload: { foo: "bar" } }], { + idempotencyKey: "my-key", + idempotencyKeyTTL: "60s", + }); + // Works for individual items as well: + await myTask.batchTrigger([ + { payload: { foo: "bar" }, options: { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" } }, + ]); + // And `trigger`: + await myTask.trigger({ foo: "bar" }, { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" }); + ``` + + ### Breaking Changes + + - We've removed the `idempotencyKey` option from `triggerAndWait` and `batchTriggerAndWait`, because it can lead to permanently frozen runs in deployed tasks. We're working on upgrading our entire system to support idempotency keys on these methods, and we'll re-add the option once that's complete. + +### Patch Changes + +- Added new batch.trigger and batch.triggerByTask methods that allows triggering multiple different tasks in a single batch: ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) + + ```ts + import { batch } from "@trigger.dev/sdk/v3"; + import type { myTask1, myTask2 } from "./trigger/tasks"; + + // Somewhere in your backend code + const response = await batch.trigger([ + { id: "task1", payload: { foo: "bar" } }, + { id: "task2", payload: { baz: "qux" } }, + ]); + + for (const run of response.runs) { + if (run.ok) { + console.log(run.output); + } else { + console.error(run.error); + } + } + ``` + + Or if you are inside of a task, you can use `triggerByTask`: + + ```ts + import { batch, task, runs } from "@trigger.dev/sdk/v3"; + + export const myParentTask = task({ + id: "myParentTask", + run: async () => { + const response = await batch.triggerByTask([ + { task: myTask1, payload: { foo: "bar" } }, + { task: myTask2, payload: { baz: "qux" } }, + ]); + + const run1 = await runs.retrieve(response.runs[0]); + console.log(run1.output); // typed as { foo: string } + + const run2 = await runs.retrieve(response.runs[1]); + console.log(run2.output); // typed as { baz: string } + + const response2 = await batch.triggerByTaskAndWait([ + { task: myTask1, payload: { foo: "bar" } }, + { task: myTask2, payload: { baz: "qux" } }, + ]); + + if (response2.runs[0].ok) { + console.log(response2.runs[0].output); // typed as { foo: string } + } + + if (response2.runs[1].ok) { + console.log(response2.runs[1].output); // typed as { baz: string } + } + }, + }); + + export const myTask1 = task({ + id: "myTask1", + run: async () => { + return { + foo: "bar", + }; + }, + }); + + export const myTask2 = task({ + id: "myTask2", + run: async () => { + return { + baz: "qux", + }; + }, + }); + ``` + +- Added ability to subscribe to a batch of runs using runs.subscribeToBatch ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) + ## 3.2.2 ## 3.2.1 diff --git a/packages/core/package.json b/packages/core/package.json index 22bc80be9d..8cf770fbca 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@trigger.dev/core", - "version": "3.2.2", + "version": "3.3.0", "description": "Core code used across the Trigger.dev SDK and platform", "license": "MIT", "publishConfig": { diff --git a/packages/react-hooks/CHANGELOG.md b/packages/react-hooks/CHANGELOG.md index 6990dbbda7..5d2250afa8 100644 --- a/packages/react-hooks/CHANGELOG.md +++ b/packages/react-hooks/CHANGELOG.md @@ -1,5 +1,40 @@ # @trigger.dev/react-hooks +## 3.3.0 + +### Minor Changes + +- Improved Batch Triggering: ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) + + - The new Batch Trigger endpoint is now asynchronous and supports up to 500 runs per request. + - The new endpoint also supports triggering multiple different tasks in a single batch request (support in the SDK coming soon). + - The existing `batchTrigger` method now supports the new endpoint, and shouldn't require any changes to your code. + + - Idempotency keys now expire after 24 hours, and you can customize the expiration time when creating a new key by using the `idempotencyKeyTTL` parameter: + + ```ts + await myTask.batchTrigger([{ payload: { foo: "bar" } }], { + idempotencyKey: "my-key", + idempotencyKeyTTL: "60s", + }); + // Works for individual items as well: + await myTask.batchTrigger([ + { payload: { foo: "bar" }, options: { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" } }, + ]); + // And `trigger`: + await myTask.trigger({ foo: "bar" }, { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" }); + ``` + + ### Breaking Changes + + - We've removed the `idempotencyKey` option from `triggerAndWait` and `batchTriggerAndWait`, because it can lead to permanently frozen runs in deployed tasks. We're working on upgrading our entire system to support idempotency keys on these methods, and we'll re-add the option once that's complete. + +### Patch Changes + +- Added ability to subscribe to a batch of runs using runs.subscribeToBatch ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) +- Updated dependencies: + - `@trigger.dev/core@3.3.0` + ## 3.2.2 ### Patch Changes diff --git a/packages/react-hooks/package.json b/packages/react-hooks/package.json index 23f69b7552..8dff3c56f6 100644 --- a/packages/react-hooks/package.json +++ b/packages/react-hooks/package.json @@ -1,6 +1,6 @@ { "name": "@trigger.dev/react-hooks", - "version": "3.2.2", + "version": "3.3.0", "description": "trigger.dev react hooks", "license": "MIT", "publishConfig": { @@ -37,7 +37,7 @@ "check-exports": "attw --pack ." }, "dependencies": { - "@trigger.dev/core": "workspace:^3.2.2", + "@trigger.dev/core": "workspace:^3.3.0", "swr": "^2.2.5" }, "devDependencies": { diff --git a/packages/rsc/CHANGELOG.md b/packages/rsc/CHANGELOG.md index 432b2cc097..19f1a0ed66 100644 --- a/packages/rsc/CHANGELOG.md +++ b/packages/rsc/CHANGELOG.md @@ -1,5 +1,12 @@ # @trigger.dev/rsc +## 3.3.0 + +### Patch Changes + +- Updated dependencies: + - `@trigger.dev/core@3.3.0` + ## 3.2.2 ### Patch Changes diff --git a/packages/rsc/package.json b/packages/rsc/package.json index cd4174ffe1..bf87761c51 100644 --- a/packages/rsc/package.json +++ b/packages/rsc/package.json @@ -1,6 +1,6 @@ { "name": "@trigger.dev/rsc", - "version": "3.2.2", + "version": "3.3.0", "description": "trigger.dev rsc", "license": "MIT", "publishConfig": { @@ -37,14 +37,14 @@ "check-exports": "attw --pack ." }, "dependencies": { - "@trigger.dev/core": "workspace:^3.2.2", + "@trigger.dev/core": "workspace:^3.3.0", "mlly": "^1.7.1", "react": "19.0.0-rc.1", "react-dom": "19.0.0-rc.1" }, "devDependencies": { "@arethetypeswrong/cli": "^0.15.4", - "@trigger.dev/build": "workspace:^3.2.2", + "@trigger.dev/build": "workspace:^3.3.0", "@types/node": "^20.14.14", "@types/react": "*", "@types/react-dom": "*", diff --git a/packages/trigger-sdk/CHANGELOG.md b/packages/trigger-sdk/CHANGELOG.md index d3ae0d7b29..06a34edc71 100644 --- a/packages/trigger-sdk/CHANGELOG.md +++ b/packages/trigger-sdk/CHANGELOG.md @@ -1,5 +1,114 @@ # @trigger.dev/sdk +## 3.3.0 + +### Minor Changes + +- Improved Batch Triggering: ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) + + - The new Batch Trigger endpoint is now asynchronous and supports up to 500 runs per request. + - The new endpoint also supports triggering multiple different tasks in a single batch request (support in the SDK coming soon). + - The existing `batchTrigger` method now supports the new endpoint, and shouldn't require any changes to your code. + + - Idempotency keys now expire after 24 hours, and you can customize the expiration time when creating a new key by using the `idempotencyKeyTTL` parameter: + + ```ts + await myTask.batchTrigger([{ payload: { foo: "bar" } }], { + idempotencyKey: "my-key", + idempotencyKeyTTL: "60s", + }); + // Works for individual items as well: + await myTask.batchTrigger([ + { payload: { foo: "bar" }, options: { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" } }, + ]); + // And `trigger`: + await myTask.trigger({ foo: "bar" }, { idempotencyKey: "my-key", idempotencyKeyTTL: "60s" }); + ``` + + ### Breaking Changes + + - We've removed the `idempotencyKey` option from `triggerAndWait` and `batchTriggerAndWait`, because it can lead to permanently frozen runs in deployed tasks. We're working on upgrading our entire system to support idempotency keys on these methods, and we'll re-add the option once that's complete. + +### Patch Changes + +- Added new batch.trigger and batch.triggerByTask methods that allows triggering multiple different tasks in a single batch: ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) + + ```ts + import { batch } from "@trigger.dev/sdk/v3"; + import type { myTask1, myTask2 } from "./trigger/tasks"; + + // Somewhere in your backend code + const response = await batch.trigger([ + { id: "task1", payload: { foo: "bar" } }, + { id: "task2", payload: { baz: "qux" } }, + ]); + + for (const run of response.runs) { + if (run.ok) { + console.log(run.output); + } else { + console.error(run.error); + } + } + ``` + + Or if you are inside of a task, you can use `triggerByTask`: + + ```ts + import { batch, task, runs } from "@trigger.dev/sdk/v3"; + + export const myParentTask = task({ + id: "myParentTask", + run: async () => { + const response = await batch.triggerByTask([ + { task: myTask1, payload: { foo: "bar" } }, + { task: myTask2, payload: { baz: "qux" } }, + ]); + + const run1 = await runs.retrieve(response.runs[0]); + console.log(run1.output); // typed as { foo: string } + + const run2 = await runs.retrieve(response.runs[1]); + console.log(run2.output); // typed as { baz: string } + + const response2 = await batch.triggerByTaskAndWait([ + { task: myTask1, payload: { foo: "bar" } }, + { task: myTask2, payload: { baz: "qux" } }, + ]); + + if (response2.runs[0].ok) { + console.log(response2.runs[0].output); // typed as { foo: string } + } + + if (response2.runs[1].ok) { + console.log(response2.runs[1].output); // typed as { baz: string } + } + }, + }); + + export const myTask1 = task({ + id: "myTask1", + run: async () => { + return { + foo: "bar", + }; + }, + }); + + export const myTask2 = task({ + id: "myTask2", + run: async () => { + return { + baz: "qux", + }; + }, + }); + ``` + +- Added ability to subscribe to a batch of runs using runs.subscribeToBatch ([#1502](https://github.com/triggerdotdev/trigger.dev/pull/1502)) +- Updated dependencies: + - `@trigger.dev/core@3.3.0` + ## 3.2.2 ### Patch Changes diff --git a/packages/trigger-sdk/package.json b/packages/trigger-sdk/package.json index ef8099c5d9..32b51d9b15 100644 --- a/packages/trigger-sdk/package.json +++ b/packages/trigger-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@trigger.dev/sdk", - "version": "3.2.2", + "version": "3.3.0", "description": "trigger.dev Node.JS SDK", "license": "MIT", "publishConfig": { @@ -48,7 +48,7 @@ "@opentelemetry/api": "1.9.0", "@opentelemetry/api-logs": "0.52.1", "@opentelemetry/semantic-conventions": "1.25.1", - "@trigger.dev/core": "workspace:3.2.2", + "@trigger.dev/core": "workspace:3.3.0", "chalk": "^5.2.0", "cronstrue": "^2.21.0", "debug": "^4.3.4",