Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 81f2d5e4ec | |||
| f249d8defa | |||
| 09aef5cda7 | |||
| 3028b6ad9d | |||
| 060b650845 | |||
| 6186a14398 | |||
| 916a353660 | |||
| 699878a5b1 | |||
| d2c9b64212 | |||
| 3102deccfb | |||
| 97c1b51332 | |||
| 4ab7082954 | |||
| 760f5de248 | |||
| de7e8c783e | |||
| 45b7af53e6 | |||
| 1fd1d26780 |
+17
-4
@@ -1,11 +1,24 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"changelog": [
|
||||
"@remix-run/changelog-github",
|
||||
{
|
||||
"repo": "triggerdotdev/trigger.dev"
|
||||
}
|
||||
],
|
||||
"commit": false,
|
||||
"fixed": [["@trigger.dev/*"]],
|
||||
"fixed": [
|
||||
[
|
||||
"@trigger.dev/*"
|
||||
]
|
||||
],
|
||||
"linked": [],
|
||||
"access": "public",
|
||||
"baseBranch": "main",
|
||||
"updateInternalDependencies": "patch",
|
||||
"ignore": ["webapp", "emails", "@trigger.dev/database"]
|
||||
}
|
||||
"ignore": [
|
||||
"webapp",
|
||||
"emails",
|
||||
"@trigger.dev/database"
|
||||
]
|
||||
}
|
||||
@@ -71,7 +71,7 @@ jobs:
|
||||
commit: "chore: Update version for release"
|
||||
title: "chore: Update version for release"
|
||||
publish: pnpm run changeset:release
|
||||
createGithubReleases: false
|
||||
createGithubReleases: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
@@ -477,7 +477,9 @@ export class PerformRunExecutionV2Service {
|
||||
}
|
||||
}
|
||||
|
||||
function prepareTasksForRun(tasks: FoundTask[]): CachedTask[] {
|
||||
function prepareTasksForRun(possibleTasks: FoundTask[]): CachedTask[] {
|
||||
const tasks = possibleTasks.filter((task) => task.status === "COMPLETED");
|
||||
|
||||
// We need to limit the cached tasks to not be too large >3.5MB when serialized
|
||||
const TOTAL_CACHED_TASK_BYTE_LIMIT = 3500000;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
---
|
||||
title: "Managing Jobs"
|
||||
description: "Managing jobs in your codebase and the dashboard"
|
||||
description: "Managing Jobs in your codebase and the dashboard"
|
||||
---
|
||||
|
||||
## Disabling jobs
|
||||
## Disabling Jobs
|
||||
|
||||
To prevent a job from processing new runs, you can disable it by setting the `enabled` option:
|
||||
To prevent a Job from processing new Runs, you can disable it by setting the `enabled` option:
|
||||
|
||||
```ts
|
||||
client.defineJob({
|
||||
@@ -15,29 +15,29 @@ client.defineJob({
|
||||
trigger: eventTrigger({ name: "example.event" }),
|
||||
enabled: false,
|
||||
run: async (payload, io, ctx) => {
|
||||
// your job code here
|
||||
// your Job code here
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
If you omit the `enabled` option, it will default to `true`.
|
||||
|
||||
The job will only be disabled in environments that have seen the `enabled = false` value. So the job will remain enabled in production until the code with the `enabled = false` is deployed to production.
|
||||
The Job will only be disabled in environments that have seen the `enabled = false` value. So the Job will remain enabled in production until the code with the `enabled = false` is deployed to production.
|
||||
|
||||
<Note>
|
||||
Currently this is the only way to disable a job. If you'd like to disable a job in the Dashboard,
|
||||
Currently this is the only way to disable a Job. If you'd like to disable a Job in the Dashboard,
|
||||
please reach out to us on [Discord](https://discord.gg/kA47vcd8P6) and let us know 👋
|
||||
</Note>
|
||||
|
||||
Once a job is disabled no **new** runs will be created for that job, and it will still be visible in the Dashboard as disabled:
|
||||
Once a Job is disabled no **new** Runs will be created for that Job, and it will still be visible in the Dashboard as disabled:
|
||||
|
||||

|
||||
|
||||
### In-progress runs
|
||||
### In-progress Runs
|
||||
|
||||
In-progress runs will be allowed to finish, even runs that are currently delayed from a call to `io.wait`. If you'd like to completely stop in-progress runs, you have two options:
|
||||
In-progress Runs will be allowed to finish, even Runs that are currently delayed from a call to `io.wait`. If you'd like to completely stop in-progress Runs, you have two options:
|
||||
|
||||
- Set the `enabled` option to false and then `throw` an error at the top of your job `run` function.
|
||||
- Set the `enabled` option to false and then `throw` an error at the top of your Job `run` function.
|
||||
|
||||
```ts
|
||||
client.defineJob({
|
||||
@@ -52,11 +52,11 @@ client.defineJob({
|
||||
});
|
||||
```
|
||||
|
||||
- Delete the job from your codebase. This will disable the job as well but also stop in progress runs.
|
||||
- Delete the Job from your codebase. This will disable the Job as well but also stop in progress Runs.
|
||||
|
||||
### Disabling in production with env vars
|
||||
|
||||
You can easily disable jobs in production using env vars so you don't have to deploy new code to disable a job.
|
||||
You can easily disable Jobs in production using env vars so you don't have to deploy new code to disable a Job.
|
||||
|
||||
```ts
|
||||
client.defineJob({
|
||||
@@ -66,19 +66,19 @@ client.defineJob({
|
||||
trigger: eventTrigger({ name: "example.event" }),
|
||||
enabled: process.env.TRIGGER_JOBS_DISABLED === "true",
|
||||
run: async (payload, io, ctx) => {
|
||||
// your job code here
|
||||
// your Job code here
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Then you can disable the job in production by setting the `TRIGGER_JOBS_DISABLED` env var to `"true"`. And removing the env var will re-enable the job.
|
||||
Then you can disable the Job in production by setting the `TRIGGER_JOBS_DISABLED` env var to `"true"`. And removing the env var will re-enable the Job.
|
||||
|
||||
## Deleting jobs
|
||||
## Deleting Jobs
|
||||
|
||||
Once you have disabled a job in all environments, you can delete it from the dashboard by navigating to the Job list page and clicking the "triple-dot" menu next to the job you want to delete:
|
||||
Once you have disabled a Job in all environments, you can delete it from the dashboard by navigating to the Job list page and clicking the "triple-dot" menu next to the Job you want to delete:
|
||||
|
||||

|
||||
|
||||
This will bring up a dialog confirming that you want to delete the job and all of its history:
|
||||
This will bring up a dialog confirming that you want to delete the Job and all of its history:
|
||||
|
||||

|
||||
|
||||
@@ -29,7 +29,7 @@ We provide an official Trigger.dev [docker image](https://github.com/triggerdotd
|
||||
<Card
|
||||
title="Render.com"
|
||||
icon="draw-square"
|
||||
href="/documentation/guides/self-hosting/flyio"
|
||||
href="/documentation/guides/self-hosting/render"
|
||||
>
|
||||
Easily deploy to Render.com
|
||||
</Card>
|
||||
|
||||
@@ -74,10 +74,11 @@ Both of these secrets should be set to the base URL of your fly application. For
|
||||
|
||||
3. `DIRECT_URL`
|
||||
|
||||
This needs to be set to the database connection string that was printed to your terminal after the creation step above:
|
||||
This needs to match the value of `DATABASE_URL` which was printed to your terminal after the creation step above:
|
||||
|
||||
```sh
|
||||
Connection string: postgres://postgres:<PASSWORD>@<fly db name>.flycast:5432
|
||||
The following secret was added to <app name>:
|
||||
DATABASE_URL=postgres://postgres:<PASSWORD>@<fly db name>.flycast:5432/<app name>?sslmode=disable
|
||||
```
|
||||
|
||||
### Optional
|
||||
@@ -111,7 +112,7 @@ fly secrets set \
|
||||
SESSION_SECRET=<random string> \
|
||||
LOGIN_ORIGIN="https://<fly app name>.fly.dev" \
|
||||
APP_ORIGIN="https://<fly app name>.fly.dev" \
|
||||
DIRECT_URL="postgres://postgres:<PASSWORD>@<fly db name>.flycast:5432" \
|
||||
DIRECT_URL="postgres://postgres:<PASSWORD>@<fly db name>.flycast:5432/<app name>?sslmode=disable" \
|
||||
FROM_EMAIL="Acme Inc. <hello@yourdomain.com>" \
|
||||
REPLY_TO_EMAIL="Acme Inc. <reply@yourdomain.com>" \
|
||||
RESEND_API_KEY=<your API Key> \
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
---
|
||||
title: Stripe
|
||||
---
|
||||
|
||||
<Snippet file="integration-getting-started.mdx" />
|
||||
|
||||
## Installation
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```bash npm
|
||||
npm install @trigger.dev/stripe@latest
|
||||
```
|
||||
|
||||
```bash pnpm
|
||||
pnpm install @trigger.dev/stripe@latest
|
||||
```
|
||||
|
||||
```bash yarn
|
||||
yarn add @trigger.dev/stripe@latest
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
## Authentication
|
||||
|
||||
The Stripe integration supports secret API Keys
|
||||
|
||||
```ts
|
||||
import { Stripe } from "@trigger.dev/stripe";
|
||||
|
||||
const stripe = new Stripe({
|
||||
id: "stripe",
|
||||
apiKey: process.env.STRIPE_API_KEY!,
|
||||
});
|
||||
```
|
||||
|
||||
## Triggers
|
||||
|
||||
The Stripe integration exposes a number of triggers that can be used on a job, powered by Stripe webhooks.
|
||||
|
||||
```ts
|
||||
client.defineJob({
|
||||
id: "stripe-price",
|
||||
name: "Stripe Price",
|
||||
version: "0.1.0",
|
||||
trigger: stripe.onPriceCreated(),
|
||||
run: async (payload, io, ctx) => {
|
||||
console.log(ctx.event.name); // "price.created"
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
As you can see above, the job will be triggered on the `price.created` event. If you'd like to trigger a job on multiple events, you can use the aggregate version of the trigger:
|
||||
|
||||
```ts
|
||||
client.defineJob({
|
||||
id: "stripe-price",
|
||||
name: "Stripe Price",
|
||||
version: "0.1.0",
|
||||
trigger: stripe.onPrice(),
|
||||
run: async (payload, io, ctx) => {
|
||||
console.log(ctx.event.name); // "price.created", "price.updated", "price.deleted"
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
"Aggregate" triggers also give you the ability to filter on specific events:
|
||||
|
||||
```ts
|
||||
client.defineJob({
|
||||
id: "stripe-price",
|
||||
name: "Stripe Price",
|
||||
version: "0.1.0",
|
||||
trigger: stripe.onPrice({
|
||||
events: ["price.created", "price.updated"],
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
console.log(ctx.event.name); // "price.created", "price.updated"
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Available triggers are listed below:
|
||||
|
||||
| Function Name | Events | Description | Aggregate Version |
|
||||
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | ------------------------ |
|
||||
| `onCharge` | `charge.succeeded`, `charge.failed`, `charge.captured`, `charge.refunded`, `charge.updated` | Triggered on all charge events | ✔️ |
|
||||
| `onChargeSucceeded` | `charge.succeeded` | Triggered on charge succeeded events | `onCharge` |
|
||||
| `onChargeFailed` | `charge.failed` | Triggered on charge failed events | `onCharge` |
|
||||
| `onChargeCaptured` | `charge.captured` | Triggered on charge captured events | `onCharge` |
|
||||
| `onChargeRefunded` | `charge.refunded` | Triggered on charge refunded events | `onCharge` |
|
||||
| `onChargeUpdated` | `charge.updated` | Triggered on charge updated events | `onCharge` |
|
||||
| `onProduct` | `product.created`, `product.updated`, `product.deleted` | Triggered on all product events | ✔️ |
|
||||
| `onProductCreated` | `product.created` | Triggered on product created events | `onProduct` |
|
||||
| `onProductUpdated` | `product.updated` | Triggered on product updated events | `onProduct` |
|
||||
| `onProductDeleted` | `product.deleted` | Triggered on product deleted events | `onProduct` |
|
||||
| `onPrice` | `price.created`, `price.updated`, `price.deleted` | Triggered on all price events | ✔️ |
|
||||
| `onPriceCreated` | `price.created` | Triggered on price created events | `onPrice` |
|
||||
| `onPriceUpdated` | `price.updated` | Triggered on price updated events | `onPrice` |
|
||||
| `onPriceDeleted` | `price.deleted` | Triggered on price deleted events | `onPrice` |
|
||||
| `onCheckoutSession` | `checkout.session.completed`, `checkout.session.async_payment_succeeded`, `checkout.session.async_payment_failed`, `checkout.session.expired` | Triggered on all checkout session events | ✔️ |
|
||||
| `onCheckoutSessionCompleted` | `checkout.session.completed` | Triggered on checkout session completed events | `onCheckoutSession` |
|
||||
| `onCheckoutSessionExpired` | `checkout.session.expired` | Triggered on checkout session expired events | `onCheckoutSession` |
|
||||
| `onCustomerSubscription` | `customer.subscription.created`, `customer.subscription.updated`, `customer.subscription.deleted`, `customer.subscription.paused`, `customer.subscription.pending_updated_applied`, `customer.subscription.pending_update_expired`, `customer.subscription.resumed` | Triggered on all customer subscription events | ✔️ |
|
||||
| `onCustomerSubscriptionCreated` | `customer.subscription.created` | Triggered on customer subscription created events | `onCustomerSubscription` |
|
||||
| `onCustomerSubscriptionUpdated` | `customer.subscription.updated` | Triggered on customer subscription updated events | `onCustomerSubscription` |
|
||||
| `onCustomerSubscriptionDeleted` | `customer.subscription.deleted` | Triggered on customer subscription deleted events | `onCustomerSubscription` |
|
||||
| `onCustomerSubscriptionPaused` | `customer.subscription.paused` | Triggered on customer subscription paused events | `onCustomerSubscription` |
|
||||
| `onCustomerSubscriptionPending` | `customer.subscription.pending_updated_applied`, `customer.subscription.pending_update_expired` | Triggered on customer subscription pending events | `onCustomerSubscription` |
|
||||
| `onCustomerSubscriptionResumed` | `customer.subscription.resumed` | Triggered on customer subscription resumed events | `onCustomerSubscription` |
|
||||
| `onCustomer` | `customer.created`, `customer.updated`, `customer.deleted` | Triggered on all customer events | ✔️ |
|
||||
| `onCustomerCreated` | `customer.created` | Triggered on customer created events | `onCustomer` |
|
||||
| `onCustomerUpdated` | `customer.updated` | Triggered on customer updated events | `onCustomer` |
|
||||
| `onCustomerDeleted` | `customer.deleted` | Triggered on customer deleted events | `onCustomer` |
|
||||
| `onExternalAccount` | `account.external_account.created`, `account.external_account.updated`, `account.external_account.deleted` | Triggered on all external account events | ✔️ |
|
||||
| `onExternalAccountCreated` | `account.external_account.created` | Triggered on external account created events | `onExternalAccount` |
|
||||
| `onExternalAccountUpdated` | `account.external_account.updated` | Triggered on external account updated events | `onExternalAccount` |
|
||||
| `onExternalAccountDeleted` | `account.external_account.deleted` | Triggered on external account deleted events | `onExternalAccount` |
|
||||
| `onPerson` | `account.person.created`, `account.person.updated`, `account.person.deleted` | Triggered on all person events | ✔️ |
|
||||
| `onPersonCreated` | `account.person.created` | Triggered on person created events | `onPerson` |
|
||||
| `onPersonUpdated` | `account.person.updated` | Triggered on person updated events | `onPerson` |
|
||||
| `onPersonDeleted` | `account.person.deleted` | Triggered on person deleted events | `onPerson` |
|
||||
| `onAccountUpdated` | `account.updated` | Triggered on account updated events | N/A |
|
||||
|
||||
If there are any triggers missing that you'd like to see added, please [open a new GitHub Issue](https://github.com/triggerdotdev/trigger.dev/issues/new)
|
||||
|
||||
## Tasks
|
||||
|
||||
You can make reliable calls to the Stripe API inside of jobs using the exposed stripe tasks:
|
||||
|
||||
```ts
|
||||
const stripe = new Stripe({
|
||||
id: "stripe",
|
||||
apiKey: process.env["STRIPE_API_KEY"]!,
|
||||
});
|
||||
|
||||
client.defineJob({
|
||||
id: "stripe-example-1",
|
||||
name: "Stripe Example 1",
|
||||
version: "0.1.0",
|
||||
trigger: eventTrigger({
|
||||
name: "stripe.example",
|
||||
schema: z.object({
|
||||
customerId: z.string(),
|
||||
source: z.string(),
|
||||
}),
|
||||
}),
|
||||
integrations: {
|
||||
stripe,
|
||||
},
|
||||
run: async (payload, io, ctx) => {
|
||||
await io.stripe.createCharge("create-charge", {
|
||||
amount: 100,
|
||||
currency: "usd",
|
||||
source: payload.source,
|
||||
customer: payload.customerId,
|
||||
});
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
We automatically fill in the `idempotencyKey` for you, so we can gaurentee that the API call will only be executed once.
|
||||
|
||||
Available tasks are listed below:
|
||||
|
||||
| Function Name | Description |
|
||||
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `createCharge` | Use the Payment Intents API to initiate a new payment instead of using this method. Confirmation of the PaymentIntent creates the Charge object used to request payment, so this method is limited to legacy integrations. |
|
||||
| `createCustomer` | Creates a new customer object |
|
||||
| `updateCustomer` | Updates the specified customer by setting the values of the parameters passed |
|
||||
| `retrieveSubscription` | Retrieves the subscription with the given ID. |
|
||||
| `createCheckoutSession` | Creates a new Checkout Session object. |
|
||||
|
||||
If there are any tasks missing that you'd like to see added, please [open a new GitHub Issue](https://github.com/triggerdotdev/trigger.dev/issues/new)
|
||||
|
||||
## Using the underlying Stripe client
|
||||
|
||||
You can use the underlying client to do anything the [stripe-node](https://github.com/stripe/stripe-node) client supports by using the `client` property on the integration:
|
||||
|
||||
```ts
|
||||
const stripe = new Stripe({
|
||||
id: "stripe",
|
||||
apiKey: process.env["STRIPE_API_KEY"]!,
|
||||
});
|
||||
|
||||
client.defineJob({
|
||||
id: "stripe-example-1",
|
||||
name: "Stripe Example 1",
|
||||
version: "0.1.0",
|
||||
trigger: eventTrigger({
|
||||
name: "stripe.example",
|
||||
}),
|
||||
integrations: {
|
||||
stripe,
|
||||
},
|
||||
run: async (payload, io, ctx) => {
|
||||
await io.runTask("create-price", { name: "Create Price" }, async (task) => {
|
||||
return stripe.client.prices.create(
|
||||
{
|
||||
unit_amount: 2000,
|
||||
currency: "usd",
|
||||
product_data: {
|
||||
name: "T-shirt",
|
||||
},
|
||||
},
|
||||
{
|
||||
idempotencyKey: task.idempotencyKey,
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Make sure to pass the `idempotencyKey` to the underlying client to ensure that the API call is only executed once. This is only needed for mutating API calls.
|
||||
@@ -193,6 +193,7 @@
|
||||
"integrations/apis/openai"
|
||||
]
|
||||
},
|
||||
"integrations/apis/stripe",
|
||||
"integrations/apis/plain",
|
||||
{
|
||||
"group": "Resend",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createExpressServer } from "@trigger.dev/express";
|
||||
import { TriggerClient, eventTrigger } from "@trigger.dev/sdk";
|
||||
import { z } from "zod";
|
||||
|
||||
export const client = new TriggerClient({
|
||||
id: "job-catalog",
|
||||
@@ -56,4 +57,45 @@ client.defineJob({
|
||||
},
|
||||
});
|
||||
|
||||
client.defineJob({
|
||||
id: "example-job",
|
||||
name: "Example Job: a joke with a delay",
|
||||
version: "0.0.2",
|
||||
trigger: eventTrigger({
|
||||
name: "shayan.event",
|
||||
schema: z.object({
|
||||
userId: z.string(),
|
||||
delay: z.number(),
|
||||
}),
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
await io.wait("sleeping", payload.delay);
|
||||
|
||||
await io.runTask("init", { name: "init" }, async () => {
|
||||
console.log("init function ran", payload.userId);
|
||||
});
|
||||
|
||||
await io.runTask("failable", { name: "task-1", retry: { limit: 3 } }, async (task) => {
|
||||
if (task.attempts > 2) {
|
||||
console.log("task succeeded");
|
||||
return {
|
||||
ok: true,
|
||||
};
|
||||
}
|
||||
console.log("task failed");
|
||||
throw new Error(`Task failed on ${task.attempts} attempt(s)`);
|
||||
});
|
||||
|
||||
await io.runTask(
|
||||
"log",
|
||||
{
|
||||
name: "log",
|
||||
},
|
||||
async () => {
|
||||
console.log("hello from the job", payload.userId);
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
createExpressServer(client);
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# @trigger.dev/github
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
- `@trigger.dev/integration-kit@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/integration-kit@2.0.12
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/github",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "The official GitHub integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -29,8 +29,8 @@
|
||||
"@octokit/request": "^6.2.5",
|
||||
"@octokit/request-error": "^4.0.1",
|
||||
"@octokit/webhooks": "^10.4.0",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.13",
|
||||
"octokit": "^2.0.14",
|
||||
"zod": "3.21.4"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# @trigger.dev/slack
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
- `@trigger.dev/integration-kit@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/integration-kit@2.0.12
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/openai",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "The official OpenAI integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -25,8 +25,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"openai": "^4.2.0",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.11"
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.13"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.8.0"
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# @trigger.dev/plain
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
- `@trigger.dev/integration-kit@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/integration-kit@2.0.12
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/plain",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "The official Plain.com integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -24,8 +24,8 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.13",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"@team-plain/typescript-sdk": "^2.7.0"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# @trigger.dev/resend
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
- `@trigger.dev/integration-kit@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/integration-kit@2.0.12
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/resend",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "The official Resend.com integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -24,8 +24,8 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.13",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"resend": "^0.9.1"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# @trigger.dev/sendgrid
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
- `@trigger.dev/integration-kit@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/integration-kit@2.0.12
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/sendgrid",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "Trigger.dev integration for @sendgrid/mail",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sendgrid/mail": "^7.7.0",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.11"
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.13"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.8.0"
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# @trigger.dev/slack
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/slack",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "The official Slack integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@slack/web-api": "^6.8.1",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"zod": "3.21.4"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
# @trigger.dev/stripe
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
- `@trigger.dev/integration-kit@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 760f5de2: Adding additional Stripe triggers for account.updated, account.external*account.*, customer._, person._, and charge.\_
|
||||
- @trigger.dev/integration-kit@2.0.12
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/stripe",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "Trigger.dev integration for stripe",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -26,8 +26,8 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.13",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"stripe": "^12.14.0",
|
||||
"zod": "3.21.4"
|
||||
},
|
||||
|
||||
@@ -6,7 +6,17 @@ import {
|
||||
pausedSubscriptionExample,
|
||||
updatedSubscriptionExample,
|
||||
} from "./examples";
|
||||
import { OnCheckoutSession, OnCustomerSubscription, OnPriceEvent, OnProductEvent } from "./types";
|
||||
import {
|
||||
OnAccountEvent,
|
||||
OnChargeEvent,
|
||||
OnCheckoutSession,
|
||||
OnCustomerEvent,
|
||||
OnCustomerSubscription,
|
||||
OnExternalAccountEvent,
|
||||
OnPersonEvent,
|
||||
OnPriceEvent,
|
||||
OnProductEvent,
|
||||
} from "./types";
|
||||
|
||||
export const onPriceCreated: EventSpecification<OnPriceEvent> = {
|
||||
name: "price.created",
|
||||
@@ -451,3 +461,252 @@ export const onCustomerSubscriptionUpdated: EventSpecification<OnCustomerSubscri
|
||||
{ label: "Status", text: payload.status },
|
||||
],
|
||||
};
|
||||
|
||||
export const onAccountUpdated: EventSpecification<OnAccountEvent> = {
|
||||
name: "account.updated",
|
||||
title: "On Account Updated",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnAccountEvent,
|
||||
runProperties: (payload) => [
|
||||
{ label: "Account ID", text: payload.id },
|
||||
...(payload.business_type ? [{ label: "Business Type", text: payload.business_type }] : []),
|
||||
],
|
||||
};
|
||||
|
||||
export const onCustomer: EventSpecification<OnCustomerEvent> = {
|
||||
name: ["customer.created", "customer.deleted", "customer.updated"],
|
||||
title: "On Customer Event",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnCustomerEvent,
|
||||
runProperties: (payload) => [{ label: "Customer ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onCustomerCreated: EventSpecification<OnCustomerEvent> = {
|
||||
name: "customer.created",
|
||||
title: "On Customer Created",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnCustomerEvent,
|
||||
runProperties: (payload) => [{ label: "Customer ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onCustomerDeleted: EventSpecification<OnCustomerEvent> = {
|
||||
name: "customer.deleted",
|
||||
title: "On Customer Deleted",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnCustomerEvent,
|
||||
runProperties: (payload) => [{ label: "Customer ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onCustomerUpdated: EventSpecification<OnCustomerEvent> = {
|
||||
name: "customer.updated",
|
||||
title: "On Customer Updated",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnCustomerEvent,
|
||||
runProperties: (payload) => [{ label: "Customer ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onCharge: EventSpecification<OnChargeEvent> = {
|
||||
name: [
|
||||
"charge.captured",
|
||||
"charge.expired",
|
||||
"charge.failed",
|
||||
"charge.pending",
|
||||
"charge.refunded",
|
||||
"charge.succeeded",
|
||||
"charge.updated",
|
||||
],
|
||||
title: "On Charge Event",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnChargeEvent,
|
||||
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onChargeCaptured: EventSpecification<OnChargeEvent> = {
|
||||
name: "charge.captured",
|
||||
title: "On Charge Captured",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnChargeEvent,
|
||||
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onChargeExpired: EventSpecification<OnChargeEvent> = {
|
||||
name: "charge.expired",
|
||||
title: "On Charge Expired",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnChargeEvent,
|
||||
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onChargeFailed: EventSpecification<OnChargeEvent> = {
|
||||
name: "charge.failed",
|
||||
title: "On Charge Failed",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnChargeEvent,
|
||||
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onChargePending: EventSpecification<OnChargeEvent> = {
|
||||
name: "charge.pending",
|
||||
title: "On Charge Pending",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnChargeEvent,
|
||||
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onChargeRefunded: EventSpecification<OnChargeEvent> = {
|
||||
name: "charge.refunded",
|
||||
title: "On Charge Refunded",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnChargeEvent,
|
||||
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onChargeSucceeded: EventSpecification<OnChargeEvent> = {
|
||||
name: "charge.succeeded",
|
||||
title: "On Charge Succeeded",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnChargeEvent,
|
||||
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onChargeUpdated: EventSpecification<OnChargeEvent> = {
|
||||
name: "charge.updated",
|
||||
title: "On Charge Updated",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnChargeEvent,
|
||||
runProperties: (payload) => [{ label: "Charge ID", text: payload.id }],
|
||||
};
|
||||
|
||||
export const onExternalAccount: EventSpecification<OnExternalAccountEvent> = {
|
||||
name: [
|
||||
"account.external_account.created",
|
||||
"account.external_account.deleted",
|
||||
"account.external_account.updated",
|
||||
],
|
||||
title: "On External Account Event",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnExternalAccountEvent,
|
||||
runProperties: (payload) => [
|
||||
{ label: "Type", text: payload.object },
|
||||
{ label: payload.object === "bank_account" ? "Bank Account ID" : "Card ID", text: payload.id },
|
||||
],
|
||||
};
|
||||
|
||||
export const onExternalAccountCreated: EventSpecification<OnExternalAccountEvent> = {
|
||||
name: "account.external_account.created",
|
||||
title: "On External Account Created",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnExternalAccountEvent,
|
||||
runProperties: (payload) => [
|
||||
{ label: "Type", text: payload.object },
|
||||
{ label: payload.object === "bank_account" ? "Bank Account ID" : "Card ID", text: payload.id },
|
||||
],
|
||||
};
|
||||
|
||||
export const onExternalAccountDeleted: EventSpecification<OnExternalAccountEvent> = {
|
||||
name: "account.external_account.deleted",
|
||||
title: "On External Account Deleted",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnExternalAccountEvent,
|
||||
runProperties: (payload) => [
|
||||
{ label: "Type", text: payload.object },
|
||||
{ label: payload.object === "bank_account" ? "Bank Account ID" : "Card ID", text: payload.id },
|
||||
],
|
||||
};
|
||||
|
||||
export const onExternalAccountUpdated: EventSpecification<OnExternalAccountEvent> = {
|
||||
name: "account.external_account.updated",
|
||||
title: "On External Account Updated",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnExternalAccountEvent,
|
||||
runProperties: (payload) => [
|
||||
{ label: "Type", text: payload.object },
|
||||
{ label: payload.object === "bank_account" ? "Bank Account ID" : "Card ID", text: payload.id },
|
||||
],
|
||||
};
|
||||
|
||||
export const onPerson: EventSpecification<OnPersonEvent> = {
|
||||
name: ["person.created", "person.deleted", "person.updated"],
|
||||
title: "On Person Event",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnPersonEvent,
|
||||
runProperties: (payload) => [
|
||||
{ label: "Person ID", text: payload.id },
|
||||
{ label: "Account", text: payload.account },
|
||||
],
|
||||
};
|
||||
|
||||
export const onPersonCreated: EventSpecification<OnPersonEvent> = {
|
||||
name: "person.created",
|
||||
title: "On Person Created",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnPersonEvent,
|
||||
runProperties: (payload) => [
|
||||
{ label: "Person ID", text: payload.id },
|
||||
{ label: "Account", text: payload.account },
|
||||
],
|
||||
};
|
||||
|
||||
export const onPersonDeleted: EventSpecification<OnPersonEvent> = {
|
||||
name: "person.deleted",
|
||||
title: "On Person Deleted",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnPersonEvent,
|
||||
runProperties: (payload) => [
|
||||
{ label: "Person ID", text: payload.id },
|
||||
{ label: "Account", text: payload.account },
|
||||
],
|
||||
};
|
||||
|
||||
export const onPersonUpdated: EventSpecification<OnPersonEvent> = {
|
||||
name: "person.updated",
|
||||
title: "On Person Updated",
|
||||
source: "stripe.com",
|
||||
icon: "stripe",
|
||||
examples: [],
|
||||
parsePayload: (payload) => payload as OnPersonEvent,
|
||||
runProperties: (payload) => [
|
||||
{ label: "Person ID", text: payload.id },
|
||||
{ label: "Account", text: payload.account },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -338,6 +338,289 @@ export class Stripe implements StripeIntegration {
|
||||
params ?? { connect: false }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever an account status or property has changed.
|
||||
*/
|
||||
onAccountUpdated(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onAccountUpdated, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs on customer.created, customer.deleted, and customer.updated
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* stripe.onCustomer()
|
||||
* ```
|
||||
*
|
||||
* You can detect the event name in your job by using the `ctx.event.name` property:
|
||||
*
|
||||
* ```ts
|
||||
* client.defineJob({
|
||||
* id: "stripe-example",
|
||||
* name: "Stripe Example",
|
||||
* version: "0.1.0",
|
||||
* trigger: stripe.onCustomer(),
|
||||
* run: async (payload, io, ctx) => {
|
||||
* console.log(ctx.event.name); // "customer.created" or "customer.deleted"
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
onCustomer(
|
||||
params?: TriggerParams & {
|
||||
events?: Array<"customer.created" | "customer.deleted">;
|
||||
}
|
||||
) {
|
||||
const event = {
|
||||
...events.onCustomer,
|
||||
name: params?.events ?? events.onCustomer.name,
|
||||
};
|
||||
|
||||
return createTrigger(this.source, event, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a new customer is created.
|
||||
*/
|
||||
onCustomerCreated(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onCustomerCreated, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a new customer is deleted.
|
||||
*/
|
||||
onCustomerDeleted(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onCustomerDeleted, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a new customer is updated.
|
||||
*/
|
||||
onCustomerUpdated(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onCustomerUpdated, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs on any charge.* event. Accepts an optional array of events to filter on. By default it will listen to all charge.* events.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* stripe.onCharge({ events: ["charge.refunded", "charge.succeeded"] })
|
||||
* ```
|
||||
*
|
||||
* You can detect the event name in your job by using the `ctx.event.name` property:
|
||||
*
|
||||
* ```ts
|
||||
* client.defineJob({
|
||||
* id: "stripe-example",
|
||||
* name: "Stripe Example",
|
||||
* version: "0.1.0",
|
||||
* trigger: stripe.onCharge({ events: ["charge.refunded", "charge.succeeded"] }),
|
||||
* run: async (payload, io, ctx) => {
|
||||
* console.log(ctx.event.name); // "charge.refunded" or "charge.succeeded"
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
onCharge(
|
||||
params?: TriggerParams & {
|
||||
events?: Array<
|
||||
| "charge.captured"
|
||||
| "charge.expired"
|
||||
| "charge.failed"
|
||||
| "charge.pending"
|
||||
| "charge.refunded"
|
||||
| "charge.succeeded"
|
||||
| "charge.updated"
|
||||
>;
|
||||
}
|
||||
) {
|
||||
const event = {
|
||||
...events.onCharge,
|
||||
name: params?.events ?? events.onCharge.name,
|
||||
};
|
||||
|
||||
return createTrigger(this.source, event, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a previously uncaptured charge is captured
|
||||
*/
|
||||
onChargeCaptured(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onChargeCaptured, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever an uncaptured charge expires.
|
||||
*/
|
||||
onChargeExpired(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onChargeExpired, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a failed charge attempt occurs
|
||||
*/
|
||||
onChargeFailed(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onChargeFailed, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a pending charge is created
|
||||
*/
|
||||
onChargePending(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onChargePending, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a charge is refunded, including partial refunds
|
||||
*/
|
||||
onChargeRefunded(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onChargeRefunded, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a charge is successful
|
||||
*/
|
||||
onChargeSucceeded(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onChargeSucceeded, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a charge description or metadata is updated, or upon an asynchronous capture
|
||||
*/
|
||||
onChargeUpdated(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onChargeUpdated, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs on any account.external_account.* event. Accepts an optional array of events to filter on. By default it will listen to all charge.* events.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* stripe.onExternalAccount({ events: ["account.external_account.created", "account.external_account.deleted"] })
|
||||
* ```
|
||||
*
|
||||
* You can detect the event name in your job by using the `ctx.event.name` property:
|
||||
*
|
||||
* ```ts
|
||||
* client.defineJob({
|
||||
* id: "stripe-example",
|
||||
* name: "Stripe Example",
|
||||
* version: "0.1.0",
|
||||
* trigger: stripe.onExternalAccount({ events: ["account.external_account.created", "account.external_account.deleted"] }),
|
||||
* run: async (payload, io, ctx) => {
|
||||
* console.log(ctx.event.name); // "account.external_account.created" or "account.external_account.deleted"
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
onExternalAccount(
|
||||
params?: TriggerParams & {
|
||||
events?: Array<
|
||||
| "account.external_account.created"
|
||||
| "account.external_account.deleted"
|
||||
| "account.external_account.updated"
|
||||
>;
|
||||
}
|
||||
) {
|
||||
const event = {
|
||||
...events.onExternalAccount,
|
||||
name: params?.events ?? events.onExternalAccount.name,
|
||||
};
|
||||
|
||||
return createTrigger(this.source, event, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever an external account is created.
|
||||
* */
|
||||
onExternalAccountCreated(params?: TriggerParams) {
|
||||
return createTrigger(
|
||||
this.source,
|
||||
events.onExternalAccountCreated,
|
||||
params ?? { connect: false }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever an external account is deleted.
|
||||
* */
|
||||
onExternalAccountDeleted(params?: TriggerParams) {
|
||||
return createTrigger(
|
||||
this.source,
|
||||
events.onExternalAccountDeleted,
|
||||
params ?? { connect: false }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever an external account is updated.
|
||||
* */
|
||||
onExternalAccountUpdated(params?: TriggerParams) {
|
||||
return createTrigger(
|
||||
this.source,
|
||||
events.onExternalAccountUpdated,
|
||||
params ?? { connect: false }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs on any person.* event. Accepts an optional array of events to filter on. By default it will listen to all person.* events.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* stripe.onPerson({ events: ["person.created", "person.deleted"] })
|
||||
* ```
|
||||
*
|
||||
* You can detect the event name in your job by using the `ctx.event.name` property:
|
||||
*
|
||||
* ```ts
|
||||
* client.defineJob({
|
||||
* id: "stripe-example",
|
||||
* name: "Stripe Example",
|
||||
* version: "0.1.0",
|
||||
* trigger: stripe.onPerson({ events: ["person.created", "person.deleted"] }),
|
||||
* run: async (payload, io, ctx) => {
|
||||
* console.log(ctx.event.name); // "person.created" or "person.deleted"
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
onPerson(
|
||||
params?: TriggerParams & {
|
||||
events?: Array<"person.created" | "person.deleted" | "person.updated">;
|
||||
}
|
||||
) {
|
||||
const event = {
|
||||
...events.onPerson,
|
||||
name: params?.events ?? events.onPerson.name,
|
||||
};
|
||||
|
||||
return createTrigger(this.source, event, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a person associated with an account is created.
|
||||
* */
|
||||
onPersonCreated(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onPersonCreated, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a person associated with an account is deleted.
|
||||
* */
|
||||
onPersonDeleted(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onPersonDeleted, params ?? { connect: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurs whenever a person associated with an account is updated.
|
||||
* */
|
||||
onPersonUpdated(params?: TriggerParams) {
|
||||
return createTrigger(this.source, events.onPersonUpdated, params ?? { connect: false });
|
||||
}
|
||||
}
|
||||
|
||||
export type TriggerParams = {
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
import { AuthenticatedTask } from "@trigger.dev/sdk";
|
||||
import type {
|
||||
StripeSDK,
|
||||
CreateChargeParams,
|
||||
CreateChargeResponse,
|
||||
CreateCustomerResponse,
|
||||
CreateCustomerParams,
|
||||
UpdateCustomerParams,
|
||||
UpdateCustomerResponse,
|
||||
RetrieveSubscriptionParams,
|
||||
RetrieveSubscriptionResponse,
|
||||
CreateCheckoutSessionParams,
|
||||
CreateCheckoutSessionResponse,
|
||||
CreateCustomerParams,
|
||||
CreateCustomerResponse,
|
||||
CreateWebhookParams,
|
||||
CreateWebhookResponse,
|
||||
ListWebhooksParams,
|
||||
ListWebhooksResponse,
|
||||
RetrieveSubscriptionParams,
|
||||
RetrieveSubscriptionResponse,
|
||||
StripeSDK,
|
||||
UpdateCustomerParams,
|
||||
UpdateCustomerResponse,
|
||||
UpdateWebhookParams,
|
||||
UpdateWebhookResponse,
|
||||
ListWebhooksResponse,
|
||||
ListWebhooksParams,
|
||||
} from "./types";
|
||||
import { AuthenticatedTask } from "@trigger.dev/sdk";
|
||||
import { Stripe } from "stripe";
|
||||
import { omit } from "./utils";
|
||||
|
||||
/**
|
||||
* Use the [Payment Intents API](https://stripe.com/docs/api/payment_intents) to initiate a new payment instead
|
||||
* of using this method. Confirmation of the PaymentIntent creates the Charge
|
||||
* object used to request payment, so this method is limited to legacy integrations.
|
||||
*/
|
||||
export const createCharge: AuthenticatedTask<StripeSDK, CreateChargeParams, CreateChargeResponse> =
|
||||
{
|
||||
run: async (params, client, task) => {
|
||||
@@ -124,6 +128,11 @@ export const createCustomer: AuthenticatedTask<
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer's active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer's current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.
|
||||
*
|
||||
* This request accepts mostly the same arguments as the customer creation call.
|
||||
*/
|
||||
export const updateCustomer: AuthenticatedTask<
|
||||
StripeSDK,
|
||||
UpdateCustomerParams,
|
||||
@@ -171,6 +180,9 @@ export const updateCustomer: AuthenticatedTask<
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the subscription with the given ID.
|
||||
*/
|
||||
export const retrieveSubscription: AuthenticatedTask<
|
||||
StripeSDK,
|
||||
RetrieveSubscriptionParams,
|
||||
@@ -206,6 +218,9 @@ export const retrieveSubscription: AuthenticatedTask<
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a Session object.
|
||||
*/
|
||||
export const createCheckoutSession: AuthenticatedTask<
|
||||
StripeSDK,
|
||||
CreateCheckoutSessionParams,
|
||||
|
||||
@@ -70,3 +70,14 @@ export type OnCheckoutSession =
|
||||
|
||||
export type OnCustomerSubscription =
|
||||
ExtractWebhookPayload<Stripe.DiscriminatedEvent.CustomerSubscriptionEvent>;
|
||||
|
||||
export type OnAccountEvent = ExtractWebhookPayload<Stripe.DiscriminatedEvent.AccountEvent>;
|
||||
|
||||
export type OnCustomerEvent = ExtractWebhookPayload<Stripe.DiscriminatedEvent.CustomerEvent>;
|
||||
|
||||
export type OnChargeEvent = ExtractWebhookPayload<Stripe.DiscriminatedEvent.ChargeEvent>;
|
||||
|
||||
export type OnExternalAccountEvent =
|
||||
ExtractWebhookPayload<Stripe.DiscriminatedEvent.AccountExternalAccountEvent>;
|
||||
|
||||
export type OnPersonEvent = ExtractWebhookPayload<Stripe.DiscriminatedEvent.PersonEvent>;
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# @trigger.dev/supabase
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
- `@trigger.dev/integration-kit@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/integration-kit@2.0.12
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/supabase",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "Trigger.dev integration for @supabase/supabase-js",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@supabase/supabase-js": "^2.26.0",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.13",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"supabase-management-js": "^0.1.4",
|
||||
"zod": "3.21.4"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# @trigger.dev/typeform
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
- `@trigger.dev/integration-kit@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/integration-kit@2.0.12
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/typeform",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "The official Typeform integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@typeform/api-client": "^1.8.0",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.0.13",
|
||||
"zod": "3.21.4"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
"packageManager": "pnpm@7.18.1",
|
||||
"dependencies": {
|
||||
"@changesets/cli": "^2.26.0",
|
||||
"@remix-run/changelog-github": "^0.0.5",
|
||||
"node-fetch": "2.6.x"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,18 @@
|
||||
# @trigger.dev/astro
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@trigger.dev/astro",
|
||||
"description": "An Astro-native integration for Trigger.dev background jobs platform",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"type": "module",
|
||||
"main": "main.js",
|
||||
"scripts": {},
|
||||
"peerDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"astro": "^2.10.7"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# create-trigger
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- provided a fix to the CLI dev command tunnel not working if you are already running ngrok ([#407](https://github.com/triggerdotdev/trigger.dev/pull/407))
|
||||
- fix: init will no longer fail when outside of a git repo ([`3028b6ad`](https://github.com/triggerdotdev/trigger.dev/commit/3028b6ad9d693d2f1662c4338d44ac9d3bf0da3a))
|
||||
- feat: Checks for outdated packages when running the dev command with instructions on how to update ([#412](https://github.com/triggerdotdev/trigger.dev/pull/412))
|
||||
|
||||
## 2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/cli",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "The Trigger.dev CLI",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
||||
@@ -12,6 +12,8 @@ import { getTriggerApiDetails } from "../utils/getTriggerApiDetails";
|
||||
import { logger } from "../utils/logger";
|
||||
import { resolvePath } from "../utils/parseNameAndPath";
|
||||
import { TriggerApi } from "../utils/triggerApi";
|
||||
import { run as ncuRun } from 'npm-check-updates'
|
||||
import chalk from "chalk";
|
||||
|
||||
const asyncExecFile = util.promisify(childProcess.execFile);
|
||||
|
||||
@@ -45,6 +47,7 @@ export async function devCommand(path: string, anyOptions: any) {
|
||||
const options = result.data;
|
||||
|
||||
const resolvedPath = resolvePath(path);
|
||||
await checkForOutdatedPackages(resolvedPath)
|
||||
|
||||
// Read from package.json to get the endpointId
|
||||
const endpointId = await getEndpointIdFromPackageJson(resolvedPath, options);
|
||||
@@ -205,6 +208,36 @@ export async function devCommand(path: string, anyOptions: any) {
|
||||
throttle(refresh, throttleTimeMs);
|
||||
}
|
||||
|
||||
export async function checkForOutdatedPackages(path: string) {
|
||||
|
||||
const updates = await ncuRun({
|
||||
packageFile: `${path}/package.json`,
|
||||
filter: "/trigger.dev\/.+$/",
|
||||
upgrade: false,
|
||||
}) as {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
if (typeof updates === 'undefined' || Object.keys(updates).length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const packageFile = await fs.readFile(`${path}/package.json`);
|
||||
const data = JSON.parse(Buffer.from(packageFile).toString('utf8'));
|
||||
const dependencies = data.dependencies;
|
||||
console.log(
|
||||
chalk.bgYellow('Updates available for trigger.dev packages')
|
||||
);
|
||||
console.log(
|
||||
chalk.bgBlue('Run npx @trigger.dev/cli@latest update')
|
||||
);
|
||||
|
||||
for (let dep in updates) {
|
||||
console.log(`${dep} ${dependencies[dep]} → ${updates[dep]}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export async function getEndpointIdFromPackageJson(path: string, options: DevCommandOptions) {
|
||||
if (options.clientId) {
|
||||
return options.clientId;
|
||||
@@ -258,6 +291,16 @@ async function createTunnel(port: number, spinner: Ora) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (
|
||||
typeof error.message === "string" &&
|
||||
error.message.includes("connect ECONNREFUSED 127.0.0.1:4041")
|
||||
) {
|
||||
spinner.fail(
|
||||
`Ngrok failed to create a tunnel for port ${port} because ngrok is already running`
|
||||
);
|
||||
return;
|
||||
}
|
||||
spinner.fail(`Ngrok failed to create a tunnel for port ${port}.\n${error.message}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,9 +253,19 @@ const resolveOptionsWithPrompts = async (
|
||||
// Detects if there are any uncommitted git changes at path
|
||||
async function detectGitChanges(path: string): Promise<boolean> {
|
||||
const git = simpleGit(path);
|
||||
const status = await git.status();
|
||||
|
||||
return status.files.length > 0;
|
||||
try {
|
||||
const isRepo = await git.checkIsRepo();
|
||||
|
||||
if (isRepo) {
|
||||
// Check if there are uncommitted changes
|
||||
const status = await git.status();
|
||||
return status.files.length > 0;
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function detectTypescriptProject(path: string): Promise<boolean> {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# internal-platform
|
||||
|
||||
## 2.0.13
|
||||
|
||||
## 2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/core",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "Core code used across the Trigger.dev SDK and platform",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @trigger.dev/eslint-plugin
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fixes #391, now handling jobs when using new Job instead of client.defineJob ([`3028b6ad`](https://github.com/triggerdotdev/trigger.dev/commit/3028b6ad9d693d2f1662c4338d44ac9d3bf0da3a))
|
||||
|
||||
## 2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -49,10 +49,7 @@ module.exports = {
|
||||
return property.name;
|
||||
}
|
||||
|
||||
const groupExpressionsByTask = (ExpressionStatements, map = new Map()) => ExpressionStatements.reduce((acc, { expression }) => {
|
||||
const taskName = getTaskName(expression);
|
||||
const taskKey = getKey(expression);
|
||||
|
||||
const groupByTaskKeyAndName = (acc, { taskKey, taskName }) => {
|
||||
if (acc.has(taskName)) {
|
||||
acc.get(taskName).push(taskKey);
|
||||
} else {
|
||||
@@ -60,6 +57,13 @@ module.exports = {
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
const groupExpressionsByTask = (ExpressionStatements, map = new Map()) => ExpressionStatements.reduce((acc, { expression }) => {
|
||||
const taskName = getTaskName(expression);
|
||||
const taskKey = getKey(expression);
|
||||
|
||||
return groupByTaskKeyAndName(acc, { taskKey, taskName });
|
||||
}, map);
|
||||
|
||||
const groupVariableDeclarationsByTask = VariableDeclarations => VariableDeclarations.reduce((acc, { declarations }) => {
|
||||
@@ -70,30 +74,46 @@ module.exports = {
|
||||
|
||||
const taskKey = getKey(declaration.init);
|
||||
|
||||
if (acc.has(taskName)) {
|
||||
acc.get(taskName).push(taskKey);
|
||||
} else {
|
||||
acc.set(taskName, [taskKey]);
|
||||
}
|
||||
groupByTaskKeyAndName(acc, { taskKey, taskName });
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, new Map());
|
||||
|
||||
const getInnerIfStatementBodies = (body) => body
|
||||
.filter((arg) => arg.type === 'IfStatement')
|
||||
.reduce((acc, arg) => {
|
||||
const consequent = arg.consequent.body;
|
||||
|
||||
const AlternateBodies = getInnerIfStatementBodies(consequent);
|
||||
|
||||
const body = consequent.filter((arg) => arg.type !== 'IfStatement');
|
||||
|
||||
return acc.concat(body).concat(AlternateBodies);
|
||||
}, [])
|
||||
|
||||
const getNodeBody = (node) => {
|
||||
const body = node.value.body.body;
|
||||
|
||||
return body
|
||||
.filter((arg) => arg.type !== 'IfStatement')
|
||||
.concat(getInnerIfStatementBodies(body));
|
||||
}
|
||||
|
||||
return {
|
||||
"CallExpression[callee.property.name='defineJob'] ObjectExpression BlockStatement": (node) => {
|
||||
const VariableDeclarations = node.body.filter((arg) => arg.type === 'VariableDeclaration');
|
||||
"Property[key.name='run']": (node) => {
|
||||
const body = getNodeBody(node);
|
||||
|
||||
const VariableDeclarations = body.filter((arg) => arg.type === 'VariableDeclaration');
|
||||
|
||||
const grouped = groupVariableDeclarationsByTask(VariableDeclarations);
|
||||
|
||||
const ExpressionStatements = node.body.filter((arg) => arg.type === 'ExpressionStatement');
|
||||
|
||||
|
||||
const ExpressionStatements = body.filter((arg) => arg.type === 'ExpressionStatement');
|
||||
|
||||
// it'll be a map of taskName => [key1, key2, ...]
|
||||
const groupedByTask = groupExpressionsByTask(ExpressionStatements, grouped);
|
||||
|
||||
groupedByTask.forEach((keys) => {
|
||||
const duplicated = keys.find((key, index) => keys.indexOf(key) !== index);
|
||||
|
||||
if (duplicated) {
|
||||
context.report({
|
||||
node,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/eslint-plugin",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "ESLint plugin with trigger.dev best practices",
|
||||
"keywords": [
|
||||
"eslint",
|
||||
|
||||
@@ -240,6 +240,86 @@ ruleTester.run("no-duplicated-task-keys", rule, {
|
||||
{ message: "Task key 'Get Tag' is duplicated" },
|
||||
{ message: "Task key 'Tag ' is duplicated" },
|
||||
]
|
||||
},
|
||||
{
|
||||
code: `import { Job, eventTrigger } from "@trigger.dev/sdk";
|
||||
import { client } from "@/trigger";
|
||||
|
||||
// your first job
|
||||
new Job(client, {
|
||||
id: "example-job",
|
||||
name: "Example Job",
|
||||
version: "0.0.1",
|
||||
trigger: eventTrigger({
|
||||
name: "example.event",
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
await io.runTask("example.task", { name: "Task 1" }, async () => {});
|
||||
await io.runTask("example.task", { name: "Task 2" }, async () => {});
|
||||
},
|
||||
});`,
|
||||
errors: [
|
||||
{ message: "Task key 'example.task' is duplicated" },
|
||||
]
|
||||
},
|
||||
{
|
||||
code: `import { Job, eventTrigger } from "@trigger.dev/sdk";
|
||||
import { client } from "@/trigger";
|
||||
|
||||
// your first job
|
||||
new Job(client, {
|
||||
id: "example-job",
|
||||
name: "Example Job",
|
||||
version: "0.0.1",
|
||||
trigger: eventTrigger({
|
||||
name: "example.event",
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
await io.runTask("example.task", { name: "Task 1" }, async () => {});
|
||||
|
||||
await io.anotherTask("different task", { name: "Task 1" }, async () => {});
|
||||
|
||||
if (true) {
|
||||
await io.runTask("example.task", { name: "Task 2" }, async () => {});
|
||||
|
||||
if (true) {
|
||||
await io.runTask("example.task", { name: "Task 3" }, async () => {});
|
||||
await io.anotherTask("different task", { name: "Task 1" }, async () => {});
|
||||
}
|
||||
}
|
||||
},
|
||||
});`,
|
||||
errors: [
|
||||
{ message: "Task key 'example.task' is duplicated" },
|
||||
{ message: "Task key 'different task' is duplicated" },
|
||||
]
|
||||
},
|
||||
{
|
||||
code: `import { Job, eventTrigger } from "@trigger.dev/sdk";
|
||||
import { client } from "@/trigger";
|
||||
|
||||
// your first job
|
||||
new Job(client, {
|
||||
id: "example-job",
|
||||
name: "Example Job",
|
||||
version: "0.0.1",
|
||||
trigger: eventTrigger({
|
||||
name: "example.event",
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
if (true) {
|
||||
await io.runTask("example.task", { name: "Task 1" }, async () => {});
|
||||
|
||||
if (true) {
|
||||
await io.runTask("example.task", { name: "Task 2" }, async () => {});
|
||||
await io.anotherTask("different task", { name: "Task 1" }, async () => {});
|
||||
}
|
||||
}
|
||||
},
|
||||
});`,
|
||||
errors: [
|
||||
{ message: "Task key 'example.task' is duplicated" },
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# @trigger.dev/express
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/express",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "Official Express adapter for Trigger.dev",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
@@ -19,7 +19,7 @@
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"@trigger.dev/tsconfig": "workspace:*",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/express": "^4.17.13",
|
||||
@@ -33,7 +33,7 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11"
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13"
|
||||
},
|
||||
"dependencies": {
|
||||
"@remix-run/web-fetch": "^4.3.5",
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# @trigger.dev/integration-kit
|
||||
|
||||
## 2.0.13
|
||||
|
||||
## 2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/integration-kit",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "Trigger.dev Integration Kit has helpers to make creating integrations easier",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# @trigger.dev/nextjs
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/sdk@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/sdk@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/nextjs",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "Trigger.dev Next.js integration",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
@@ -33,7 +33,7 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.0.11",
|
||||
"@trigger.dev/sdk": "workspace:^2.0.13",
|
||||
"next": ">=12.0.0 <14.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# @trigger.dev/react
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/core@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/core@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/react",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "Trigger.dev React SDK",
|
||||
"license": "MIT",
|
||||
"types": "dist/index.d.ts",
|
||||
@@ -27,7 +27,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "5.0.0-beta.2",
|
||||
"@trigger.dev/core": "workspace:^2.0.11",
|
||||
"@trigger.dev/core": "workspace:^2.0.13",
|
||||
"debug": "^4.3.4",
|
||||
"zod": "3.21.4"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @trigger.dev/sdk
|
||||
|
||||
## 2.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Only use cached tasks if they are completed, otherwise retrying tasks will be considered successful ([`916a3536`](https://github.com/triggerdotdev/trigger.dev/commit/916a353660e251946d76bdf565c26b7801d3beb8))
|
||||
- Updated dependencies:
|
||||
- `@trigger.dev/core@2.0.13`
|
||||
|
||||
## 2.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @trigger.dev/core@2.0.12
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/sdk",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.13",
|
||||
"description": "trigger.dev Node.JS SDK",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
@@ -25,7 +25,7 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/core": "workspace:^2.0.11",
|
||||
"@trigger.dev/core": "workspace:^2.0.13",
|
||||
"chalk": "^5.2.0",
|
||||
"cronstrue": "^2.21.0",
|
||||
"debug": "^4.3.4",
|
||||
|
||||
@@ -504,8 +504,8 @@ export class IO {
|
||||
|
||||
const cachedTask = this._cachedTasks.get(idempotencyKey);
|
||||
|
||||
if (cachedTask) {
|
||||
this._logger.debug("Using cached task", {
|
||||
if (cachedTask && cachedTask.status === "COMPLETED") {
|
||||
this._logger.debug("Using completed cached task", {
|
||||
idempotencyKey,
|
||||
cachedTask,
|
||||
});
|
||||
|
||||
Generated
+51
-20
@@ -7,6 +7,7 @@ importers:
|
||||
'@changesets/cli': ^2.26.0
|
||||
'@manypkg/cli': ^0.19.2
|
||||
'@playwright/test': ^1.36.2
|
||||
'@remix-run/changelog-github': ^0.0.5
|
||||
'@tailwindcss/forms': ^0.5.3
|
||||
'@tailwindcss/typography': ^0.5.8
|
||||
'@trigger.dev/cli': workspace:*
|
||||
@@ -25,6 +26,7 @@ importers:
|
||||
vitest: ^0.28.4
|
||||
dependencies:
|
||||
'@changesets/cli': 2.26.0
|
||||
'@remix-run/changelog-github': 0.0.5
|
||||
node-fetch: 2.6.7
|
||||
devDependencies:
|
||||
'@manypkg/cli': 0.19.2
|
||||
@@ -614,8 +616,8 @@ importers:
|
||||
'@octokit/types': ^9.2.3
|
||||
'@octokit/webhooks': ^10.4.0
|
||||
'@octokit/webhooks-types': ^6.10.0
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.13
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
octokit: ^2.0.14
|
||||
@@ -640,8 +642,8 @@ importers:
|
||||
|
||||
integrations/openai:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.13
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
openai: ^4.2.0
|
||||
@@ -660,8 +662,8 @@ importers:
|
||||
integrations/plain:
|
||||
specifiers:
|
||||
'@team-plain/typescript-sdk': ^2.7.0
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.13
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
rimraf: ^3.0.2
|
||||
@@ -678,8 +680,8 @@ importers:
|
||||
|
||||
integrations/resend:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.13
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
resend: ^0.9.1
|
||||
@@ -698,8 +700,8 @@ importers:
|
||||
integrations/sendgrid:
|
||||
specifiers:
|
||||
'@sendgrid/mail': ^7.7.0
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.13
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@types/node': 16.x
|
||||
rimraf: ^3.0.2
|
||||
tsup: 7.1.x
|
||||
@@ -717,7 +719,7 @@ importers:
|
||||
integrations/slack:
|
||||
specifiers:
|
||||
'@slack/web-api': ^6.8.1
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
rimraf: ^3.0.2
|
||||
@@ -735,8 +737,8 @@ importers:
|
||||
|
||||
integrations/stripe:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.13
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@types/node': 16.x
|
||||
rimraf: ^3.0.2
|
||||
stripe: ^12.14.0
|
||||
@@ -759,8 +761,8 @@ importers:
|
||||
integrations/supabase:
|
||||
specifiers:
|
||||
'@supabase/supabase-js': ^2.26.0
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.13
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@types/node': 18.x
|
||||
rimraf: ^3.0.2
|
||||
supabase-management-js: ^0.1.4
|
||||
@@ -781,8 +783,8 @@ importers:
|
||||
|
||||
integrations/typeform:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/integration-kit': workspace:^2.0.13
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@typeform/api-client': ^1.8.0
|
||||
'@types/node': 16.x
|
||||
rimraf: ^3.0.2
|
||||
@@ -987,7 +989,7 @@ importers:
|
||||
packages/express:
|
||||
specifiers:
|
||||
'@remix-run/web-fetch': ^4.3.5
|
||||
'@trigger.dev/sdk': workspace:^2.0.11
|
||||
'@trigger.dev/sdk': workspace:^2.0.13
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/debug': ^4.1.7
|
||||
'@types/express': ^4.17.13
|
||||
@@ -1056,7 +1058,7 @@ importers:
|
||||
packages/react:
|
||||
specifiers:
|
||||
'@tanstack/react-query': 5.0.0-beta.2
|
||||
'@trigger.dev/core': workspace:^2.0.11
|
||||
'@trigger.dev/core': workspace:^2.0.13
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/debug': ^4.1.7
|
||||
'@types/react': 18.2.17
|
||||
@@ -1086,7 +1088,7 @@ importers:
|
||||
|
||||
packages/trigger-sdk:
|
||||
specifiers:
|
||||
'@trigger.dev/core': workspace:^2.0.11
|
||||
'@trigger.dev/core': workspace:^2.0.13
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/debug': ^4.1.7
|
||||
'@types/node': '18'
|
||||
@@ -3778,6 +3780,15 @@ packages:
|
||||
semver: 5.7.1
|
||||
dev: false
|
||||
|
||||
/@changesets/get-github-info/0.5.2:
|
||||
resolution: {integrity: sha512-JppheLu7S114aEs157fOZDjFqUDpm7eHdq5E8SSR0gUBTEK0cNSHsrSR5a66xs0z3RWuo46QvA3vawp8BxDHvg==}
|
||||
dependencies:
|
||||
dataloader: 1.4.0
|
||||
node-fetch: 2.6.12
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
dev: false
|
||||
|
||||
/@changesets/get-release-plan/3.0.16:
|
||||
resolution: {integrity: sha512-OpP9QILpBp1bY2YNIKFzwigKh7Qe9KizRsZomzLe6pK8IUo8onkAAVUD8+JRKSr8R7d4+JRuQrfSSNlEwKyPYg==}
|
||||
dependencies:
|
||||
@@ -8712,6 +8723,17 @@ packages:
|
||||
react: 18.2.0
|
||||
dev: false
|
||||
|
||||
/@remix-run/changelog-github/0.0.5:
|
||||
resolution: {integrity: sha512-43tqwUqWqirbv6D9uzo55ASPsCJ61Ein1k/M8qn+Qpros0MmbmuzjLVPmtaxfxfe2ANX0LefLvCD0pAgr1tp4g==}
|
||||
dependencies:
|
||||
'@changesets/errors': 0.1.4
|
||||
'@changesets/get-github-info': 0.5.2
|
||||
'@changesets/types': 5.2.1
|
||||
dotenv: 8.6.0
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
dev: false
|
||||
|
||||
/@remix-run/dev/1.19.2-pre.0_36n2i74sizt32vwpdxc4husnkq:
|
||||
resolution: {integrity: sha512-8s7g8jLueKcIr5Gb7qvZRJVzfHx2KqyApGYW55LrQ63kNwZwuKHglYSMoaQGB4xUhX2cfmzW7pIcunfbh3SNyA==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
@@ -14268,6 +14290,10 @@ packages:
|
||||
engines: {node: '>= 14'}
|
||||
dev: true
|
||||
|
||||
/dataloader/1.4.0:
|
||||
resolution: {integrity: sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw==}
|
||||
dev: false
|
||||
|
||||
/date-fns/2.30.0:
|
||||
resolution: {integrity: sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==}
|
||||
engines: {node: '>=0.11'}
|
||||
@@ -14760,6 +14786,11 @@ packages:
|
||||
resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
/dotenv/8.6.0:
|
||||
resolution: {integrity: sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==}
|
||||
engines: {node: '>=10'}
|
||||
dev: false
|
||||
|
||||
/duplexer2/0.1.4:
|
||||
resolution: {integrity: sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==}
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user