Feature: Support multiple runtimes other than Node.js (#774)
🚀 Publish Trigger.dev Docker / e2e (push) Failing after 0s
🚀 Publish Trigger.dev Docker / units (push) Failing after 5s
🚀 Publish Trigger.dev Docker / typecheck (push) Failing after 5s
🚀 Publish Trigger.dev Docker / publish (push) Has been skipped

This commit is contained in:
Eric Allam
2023-12-06 10:23:37 +00:00
committed by GitHub
parent 08f7c639ef
commit 17f6f29d05
135 changed files with 2457 additions and 2421 deletions
+29
View File
@@ -0,0 +1,29 @@
---
"@trigger.dev/integration-kit": minor
"@trigger.dev/replicate": minor
"@trigger.dev/airtable": minor
"@trigger.dev/sendgrid": minor
"@trigger.dev/supabase": minor
"@trigger.dev/typeform": minor
"@trigger.dev/core-backend": minor
"@trigger.dev/shopify": minor
"@trigger.dev/sdk": minor
"@trigger.dev/github": minor
"@trigger.dev/linear": minor
"@trigger.dev/openai": minor
"@trigger.dev/resend": minor
"@trigger.dev/stripe": minor
"@trigger.dev/plain": minor
"@trigger.dev/slack": minor
"@trigger.dev/sveltekit": minor
"@trigger.dev/express": minor
"@trigger.dev/testing": minor
"@trigger.dev/nestjs": minor
"@trigger.dev/nextjs": minor
"@trigger.dev/remix": minor
"@trigger.dev/core": minor
---
Support for Deno, Bun and Cloudflare workers, as well as conditionally exporting ESM versions of the package instead of just commonjs.
Cloudflare worker support requires the node compat flag turned on (https://developers.cloudflare.com/workers/runtime-apis/nodejs/)
+6
View File
@@ -0,0 +1,6 @@
---
"@trigger.dev/hono": patch
"@trigger.dev/cli": patch
---
Added hono framework support
+10
View File
@@ -22,6 +22,16 @@ jobs:
node-version: 18
cache: "pnpm"
- name: ⎔ Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: ⎔ Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.0.15"
- name: 📥 Download deps
run: pnpm install --frozen-lockfile
+1 -1
View File
@@ -1,4 +1,4 @@
{
"deno.enablePaths": ["references/deno-reference"],
"deno.enablePaths": ["references/deno-reference", "runtime_tests/tests/deno"],
"debug.toolBarLocation": "commandCenter"
}
@@ -150,7 +150,7 @@ export function RunOverview({ run, trigger, showRerun, paths }: RunOverviewProps
<PageInfoProperty
icon={"list-numbers"}
label={"Execution Count"}
value={run.executionCount}
value={<>{run.executionCount}</>}
/>
</PageInfoGroup>
<PageInfoGroup alignment="right">
+1 -1
View File
@@ -8,4 +8,4 @@ export const EXECUTE_JOB_RETRY_LIMIT = 10;
export const MAX_RUN_YIELDED_EXECUTIONS = 100;
export const RUN_CHUNK_EXECUTION_BUFFER = 350;
export const MAX_RUN_CHUNK_EXECUTION_LIMIT = 120000; // 2 minutes
export const RESPONSE_TIMEOUT_STATUS_CODES = [408, 504];
export const VERCEL_RESPONSE_TIMEOUT_STATUS_CODES = [408, 504];
+23 -3
View File
@@ -1,4 +1,4 @@
import { RESPONSE_TIMEOUT_STATUS_CODES } from "~/consts";
import { VERCEL_RESPONSE_TIMEOUT_STATUS_CODES } from "~/consts";
import { prisma } from "~/db.server";
import { Prettify } from "~/lib.es5";
@@ -20,13 +20,33 @@ export async function findEndpoint(id: string) {
});
}
export function detectResponseIsTimeout(response?: Response) {
export function detectResponseIsTimeout(rawBody: string, response?: Response) {
if (!response) {
return false;
}
return (
RESPONSE_TIMEOUT_STATUS_CODES.includes(response.status) ||
isResponseVercelTimeout(response) ||
isResponseDenoDeployTimeout(rawBody, response) ||
isResponseCloudflareTimeout(rawBody, response)
);
}
function isResponseCloudflareTimeout(rawBody: string, response: Response) {
return (
response.status === 503 &&
rawBody.includes("Worker exceeded resource limits") &&
typeof response.headers.get("cf-ray") === "string"
);
}
function isResponseVercelTimeout(response: Response) {
return (
VERCEL_RESPONSE_TIMEOUT_STATUS_CODES.includes(response.status) ||
response.headers.get("x-vercel-error") === "FUNCTION_INVOCATION_TIMEOUT"
);
}
function isResponseDenoDeployTimeout(rawBody: string, response: Response) {
return response.status === 502 && rawBody.includes("TIME_LIMIT");
}
@@ -444,6 +444,7 @@ function addStandardRequestOptions(options: RequestInit) {
...options.headers,
"user-agent": "triggerdotdev-server/2.0.0",
"x-trigger-version": API_VERSIONS.LAZY_LOADED_CACHED_TASKS,
accept: "application/json",
},
};
}
@@ -1,4 +1,4 @@
import { MAX_RUN_CHUNK_EXECUTION_LIMIT, RESPONSE_TIMEOUT_STATUS_CODES } from "~/consts";
import { MAX_RUN_CHUNK_EXECUTION_LIMIT } from "~/consts";
import { prisma, PrismaClient } from "~/db.server";
import { EndpointApi } from "../endpointApi.server";
import { logger } from "../logger.server";
@@ -46,8 +46,10 @@ export class ProbeEndpointService {
},
});
const rawBody = await response.text();
// If the response is a 200, or it was a timeout, we can assume the endpoint is up and update the runChunkExecutionLimit
if (response.status === 200 || detectResponseIsTimeout(response)) {
if (response.status === 200 || detectResponseIsTimeout(rawBody, response)) {
await this.#prismaClient.endpoint.update({
where: {
id,
@@ -9,7 +9,7 @@ const supabase = new SupabaseManagement({
id: "__SLUG__",
});
new Job(client, {
client.defineJob({
id: "on-new-todos",
name: "On New Todos",
version: "0.1.1",
@@ -32,7 +32,7 @@ const supabase = new SupabaseManagement({
apiKey: process.env.SUPABASE_API_KEY!,
});
new Job(client, {
client.defineJob({
id: "on-new-todos",
name: "On New Todos",
version: "0.1.1",
@@ -136,7 +136,7 @@ const supabase = new Supabase<Database>({
supabaseKey: process.env.SUPABASE_API_KEY!,
});
new Job(client, {
client.defineJob({
id: "on-new-users",
name: "On New Users",
version: "0.1.1",
@@ -202,9 +202,14 @@ export class PerformRunExecutionV3Service {
forceYieldCoordinator.deregisterRun(run.id);
if (!response) {
return await this.#failRunExecutionWithRetry(run, input.lastAttempt, {
message: `Connection could not be established to the endpoint (${run.endpoint.url})`,
});
return await this.#failRunExecutionWithRetry(
run,
input.lastAttempt,
{
message: `Connection could not be established to the endpoint (${run.endpoint.url})`,
},
durationInMs
);
}
// Update the endpoint version if it has changed
@@ -285,6 +290,8 @@ export class PerformRunExecutionV3Service {
status: response.status,
runId: run.id,
endpoint: run.endpoint.url,
headers: rawHeaders,
rawBody,
});
const errorBody = safeJsonZodParse(errorParser, rawBody);
@@ -294,7 +301,12 @@ export class PerformRunExecutionV3Service {
if (response.status >= 400 && response.status <= 499) {
return await this.#failRunExecution(this.#prismaClient, run, errorBody.data);
} else {
return await this.#failRunExecutionWithRetry(run, input.lastAttempt, errorBody.data);
return await this.#failRunExecutionWithRetry(
run,
input.lastAttempt,
errorBody.data,
durationInMs
);
}
}
@@ -311,7 +323,7 @@ export class PerformRunExecutionV3Service {
);
} else {
// If the error is a timeout, we should mark this execution as succeeded (by not throwing an error) and enqueue a new execution
if (detectResponseIsTimeout(response)) {
if (detectResponseIsTimeout(rawBody, response)) {
return await this.#resumeRunExecutionAfterTimeout(
this.#prismaClient,
run,
@@ -319,9 +331,14 @@ export class PerformRunExecutionV3Service {
durationInMs
);
} else {
return await this.#failRunExecutionWithRetry(run, input.lastAttempt, {
message: `Endpoint responded with ${response.status} status code`,
});
return await this.#failRunExecutionWithRetry(
run,
input.lastAttempt,
{
message: `Endpoint responded with ${response.status} status code`,
},
durationInMs
);
}
}
}
@@ -996,6 +1013,9 @@ export class PerformRunExecutionV3Service {
executionDuration: {
increment: durationInMs,
},
executionCount: {
increment: 1,
},
endpoint: {
update: {
// Never allow the execution limit to be less than 10 seconds or more than MAX_RUN_CHUNK_EXECUTION_LIMIT
@@ -1018,7 +1038,8 @@ export class PerformRunExecutionV3Service {
async #failRunExecutionWithRetry(
run: FoundRun,
lastAttempt: boolean,
output: Record<string, any>
output: Record<string, any>,
durationInMs: number = 0
): Promise<void> {
if (lastAttempt) {
return await this.#failRunExecution(this.#prismaClient, run, output);
@@ -1028,10 +1049,16 @@ export class PerformRunExecutionV3Service {
where: { id: run.id },
data: {
status: "WAITING_TO_EXECUTE",
executionDuration: {
increment: durationInMs,
},
executionCount: {
increment: 1,
},
},
});
throw new Error(JSON.stringify(output));
await ResumeRunService.enqueue(run, this.#prismaClient);
}
async #failRunExecution(
@@ -1052,6 +1079,9 @@ export class PerformRunExecutionV3Service {
executionDuration: {
increment: durationInMs,
},
executionCount: {
increment: 1,
},
tasks: {
updateMany: {
where: {
+27 -9
View File
@@ -1,19 +1,37 @@
{
"extends": "./node18.json",
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"lib": [
"DOM",
"DOM.Iterable",
"ES2019"
],
"paths": {
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"],
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
"@trigger.dev/tsup/*": [
"../../config-packages/tsup/src/*"
],
"@trigger.dev/tsup": [
"../../config-packages/tsup/src/index"
],
"@trigger.dev/sdk/*": [
"../../packages/trigger-sdk/src/*"
],
"@trigger.dev/sdk": [
"../../packages/trigger-sdk/src/index"
],
"@trigger.dev/integration-kit/*": [
"../../packages/integration-kit/src/*"
],
"@trigger.dev/integration-kit": [
"../../packages/integration-kit/src/index"
]
},
"declaration": false,
"declarationMap": false,
"baseUrl": ".",
"stripInternal": true
},
"exclude": ["node_modules"]
}
"exclude": [
"node_modules"
]
}
+12 -2
View File
@@ -3,7 +3,17 @@
"version": "0.0.0",
"private": true,
"license": "MIT",
"main": "./src/index.ts",
"types": "./src/index.ts",
"dependencies": {
"esbuild": "^0.19.2",
"tsup": "^8.0.1"
},
"devDependencies": {
"tsup": "7.1.x"
"@types/node": "18",
"typescript": "^5.3.0"
},
"engines": {
"node": ">=18.0.0"
}
}
}
+1
View File
@@ -1,3 +1,4 @@
export { defineConfig } from "tsup";
export { deepMergeOptions } from "./utils";
export { options as integrationOptions } from "./integration";
export { options as packageOptions, defineConfig as defineConfigPackage } from "./package";
+39
View File
@@ -0,0 +1,39 @@
import { Plugin } from "esbuild";
import { Options, defineConfig as defineConfigTSUP } from "tsup";
const restoreNodeProtocolPlugin = (): Plugin => {
return {
name: "node-protocol-plugin-restorer",
setup(build) {
build.onResolve(
{
filter: /node:/,
},
async (args) => {
return { path: args.path, external: true };
}
);
},
};
};
export const options: Options = {
name: "main",
config: "tsconfig.json",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs", "esm"],
legacyOutput: false,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "recommended",
},
esbuildPlugins: [restoreNodeProtocolPlugin()],
};
export const defineConfig = defineConfigTSUP(options);
+3 -3
View File
@@ -5,15 +5,15 @@ To begin, install the necessary packages in your Remix project directory. You ca
<CodeGroup>
```bash npm
npm i @trigger.dev/sdk @trigger.dev/remix
npm i @trigger.dev/sdk@latest @trigger.dev/remix@latest
```
```bash pnpm
pnpm install @trigger.dev/sdk @trigger.dev/remix
pnpm install @trigger.dev/sdk@latest @trigger.dev/remix@latest
```
```bash yarn
yarn add @trigger.dev/sdk @trigger.dev/remix
yarn add @trigger.dev/sdk@latest @trigger.dev/remix@latest
```
</CodeGroup>
+433
View File
@@ -0,0 +1,433 @@
---
title: "Hono Quick Start"
sidebarTitle: "Hono.dev"
description: "Start creating Jobs in 5 minutes in your Hono project."
icon: "fire"
---
Hono is a fast & lightweight web framework built on top of Web Standards, and we support using Hono with Trigger.dev on Cloudflare Workers, Bun, Deno, and Node.js.
## Installing Required Packages
To begin, install the necessary packages in your Hono project:
<CodeGroup>
```bash npm
npm add @trigger.dev/sdk@latest @trigger.dev/hono@latest
```
```bash pnpm
pnpm add @trigger.dev/sdk@latest @trigger.dev/hono@latest
```
```bash yarn
yarn add @trigger.dev/sdk@latest @trigger.dev/hono@latest
```
</CodeGroup>
## Obtain the Development Server API Key
To locate your development Server API key, login to the [Trigger.dev
dashboard](https://cloud.trigger.dev) and select the Project you want to
connect to. Then click on the **Environments & API Keys** tab in the left menu.
You can copy your development Server API Key from the field at the top of this page.
(Your development key will start with `tr_dev_`).
## Configure Environment Variables
Add the following environment variables to your `.env` file (or `.dev.vars` file if you are using Cloudflare Workers):
```bash
TRIGGER_API_KEY=<development server api key>
TRIGGER_API_URL=https://api.trigger.dev # change this if you are self-hosting
```
Replace `<development server api key>` with the actual API key obtained from the previous step.
## Enable Node.js compatibility
If you are using Cloudflare Workers, you'll need to enable Node.js compatibility mode in your `wrangler.toml` file:
```toml
compatibility_flags = ["nodejs_compat"]
```
## Add Middelware to Your Hono app
Our `@trigger.dev/hono` package provides two different ways of configuring the necessary middleware needed to connect your Hono app to Trigger.dev. `addMiddleware` which should be used for Cloudflare Workers, and `createMiddleware` which can be used with Bun, Deno, and Node.js.
### Cloudflare Workers
Becase environment variables in Cloudflare Workers aren't available in the global scope, but are instead available only inside the fetch handler, we need to use the `addMiddleware` function to add the necessary middleware to your Hono app.
```ts
import { Hono } from "hono";
import { addMiddleware } from "@trigger.dev/hono";
import { TriggerClient } from "@trigger.dev/sdk";
const app = new Hono<{
Bindings: {
TRIGGER_API_KEY: string;
TRIGGER_API_URL: string;
};
}>();
addMiddleware(app, (env) => {
const client = new TriggerClient({
id: "hono-client",
apiKey: env.TRIGGER_API_KEY,
apiUrl: env.TRIGGER_API_URL,
});
return client;
});
// Your other routes here
export default app;
```
The second argument to `addMiddleware` is a function that receives the environment variables (either from `.dev.vars` in development or from Cloudflare when deployed), and returns a `TriggerClient` instance. This function will be called once per request.
If you want, you can extract our the function that creates the `TriggerClient` instance into a separate file, and import it into your `index.ts` file:
<CodeGroup>
```ts trigger-client.ts
import { TriggerClient } from "@trigger.dev/sdk";
export function triggerClient(apiKey: string, apiUrl: string) {
const client = new TriggerClient({
id: "hono-client",
apiKey,
apiUrl,
});
return client;
}
```
```ts index.ts
import { Hono } from "hono";
import { addMiddleware } from "@trigger.dev/hono";
import { triggerClient } from "./trigger-client";
const app = new Hono<{
Bindings: {
TRIGGER_API_KEY: string;
TRIGGER_API_URL: string;
};
}>();
addMiddleware(app, (env) => triggerClient(env.TRIGGER_API_KEY, env.TRIGGER_API_URL));
// Your other routes here
export default app;
```
</CodeGroup>
Now that you've created the `TriggerClient` and setup the middleware, you can add your first job:
<CodeGroup>
```ts trigger-client.ts
import { TriggerClient } from "@trigger.dev/sdk";
import { exampleJob } from "./jobs";
export function triggerClient(apiKey: string, apiUrl: string) {
const client = new TriggerClient({
id: "hono-client",
apiKey,
apiUrl,
});
exampleJob.attachToClient(client);
return client;
}
```
```ts jobs.ts
import { Job, invokeTrigger } from "@trigger.dev/sdk";
export const exampleJob = new Job({
id: "example-job",
name: "Example Job",
version: "0.0.1",
trigger: invokeTrigger(),
run: async (payload, io, ctx) => {
await io.logger.info("Hello world!", { payload });
return {
message: "Hello world!",
};
},
});
```
</CodeGroup>
As you can see above in `jobs.ts`, we define our first job using the `new Job` constructor from `@trigger.dev/sdk`, and then in `trigger-client.ts` we attach the job to the `TriggerClient` instance.
### Bun
If you are using Bun, you can use the `createMiddleware` function to create the necessary middleware to connect your Hono app to Trigger.dev and define your `TriggerClient` and jobs in the global scope:
```ts
import { createMiddleware } from "@trigger.dev/hono";
import { TriggerClient, invokeTrigger } from "@trigger.dev/sdk";
import { Hono } from "hono";
const app = new Hono();
const client = new TriggerClient({
id: "hono-client",
apiKey: Bun.env.TRIGGER_API_KEY, // Bun.env is available in the global scope
apiUrl: Bun.env.TRIGGER_API_URL, // Bun.env is available in the global scope
});
client.defineJob({
id: "example-job",
name: "Example Job",
version: "0.0.1",
trigger: invokeTrigger(),
run: async (payload, io, ctx) => {
await io.logger.info("Hello world!", { payload });
return {
message: "Hello world!",
};
},
});
app.use("/api/trigger", createMiddleware(client));
// The rest of your routes here
export default app;
```
### Deno
Deno works similarly to Bun, but the imports are slightly different. First, import the `@trigger.dev/sdk` and `@trigger.dev/hono` packages using [npm: specifiers](https://docs.deno.com/runtime/manual/node/npm_specifiers)
```ts index.ts
import { createMiddleware } from "npm:@trigger.dev/hono@latest";
import { TriggerClient, invokeTrigger } from "npm:@trigger.dev/sdk@latest";
import { Hono } from "npm:hono"; // Make sure to use the npm specifier for hono as well
```
Deno doesn't automatically load environment variables from a `.env` file, so you'll need to load them manually using the `dotenv` package:
```ts index.ts
import { load } from "https://deno.land/std@0.208.0/dotenv/mod.ts";
const env = await load();
```
Now we can create the `TriggerClient`, define our jobs, and create the middleware:
```ts index.ts
const app = new Hono();
const client = new TriggerClient({
id: "hono-client",
apiKey: env["TRIGGER_API_KEY"],
apiUrl: env["TRIGGER_API_URL"],
});
client.defineJob({
id: "example-job",
name: "Example Job",
version: "0.0.1",
trigger: invokeTrigger(),
run: async (payload, io, ctx) => {
await io.logger.info("Hello world!", { payload });
return {
message: "Hello world!",
};
},
});
app.use("/api/trigger", createMiddleware(client));
// The rest of your routes here
Deno.serve(app.fetch);
```
### Node.js
Node.js works very similarly to Deno and Bun, in that you can define the `TriggerClient` and jobs in the global scope, and then create the middleware and add it to your Hono app:
```ts index.ts
import "dotenv/config";
import { serve } from "@hono/node-server";
import { Hono } from "hono";
import { createMiddleware } from "@trigger.dev/hono";
import { TriggerClient, invokeTrigger } from "@trigger.dev/sdk";
const app = new Hono();
const client = new TriggerClient({
id: "hono-client",
apiKey: process.env.TRIGGER_API_KEY!,
apiUrl: process.env.TRIGGER_API_URL!,
});
client.defineJob({
id: "example-job",
name: "Example Job",
version: "0.0.1",
trigger: invokeTrigger(),
run: async (payload, io, ctx) => {
await io.logger.info("Hello world!", { payload });
return {
message: "Hello world!",
};
},
});
app.use("/api/trigger", createMiddleware(client));
// Your other routes here
serve(app, (info) => {
console.log(`Listening on port ${info.port}`);
});
```
## Running
### Cloudflare Workers
Run your Hono app locally, like you normally would. For example:
<CodeGroup>
```bash npm
npm run dev
```
```bash pnpm
pnpm run dev
```
```bash yarn
yarn run dev
```
</CodeGroup>
In a **_separate terminal window or tab_** run:
<CodeGroup>
```bash npm
npx @trigger.dev/cli@latest dev --client-id hono-client -p 8787 -H localhost
```
```bash pnpm
pnpm dlx @trigger.dev/cli@latest dev --client-id hono-client -p 8787 -H localhost
```
```bash yarn
yarn dlx @trigger.dev/cli@latest dev --client-id hono-client -p 8787 -H localhost
```
</CodeGroup>
### Bun
Run your Hono app locally, like you normally would. For example:
```bash
bun run index.ts
```
In a **_separate terminal window or tab_** run:
<CodeGroup>
```bash npm
npx @trigger.dev/cli@latest dev --client-id hono-client -p 8787 -H localhost
```
```bash pnpm
pnpm dlx @trigger.dev/cli@latest dev --client-id hono-client -p 8787 -H localhost
```
```bash yarn
yarn dlx @trigger.dev/cli@latest dev --client-id hono-client -p 8787 -H localhost
```
</CodeGroup>
### Deno
Run your Hono app locally, like you normally would. For example:
```bash
deno run --allow-net --allow-read --watch index.ts
```
In a **_separate terminal window or tab_** run:
<CodeGroup>
```bash npm
npx @trigger.dev/cli@latest dev --client-id hono-client -p 8000 -H 127.0.0.1
```
```bash pnpm
pnpm dlx @trigger.dev/cli@latest dev --client-id hono-client -p 8000 -H 127.0.0.1
```
```bash yarn
yarn dlx @trigger.dev/cli@latest dev --client-id hono-client -p 8000 -H 127.0.0.1
```
</CodeGroup>
### Node.js
Run your Hono app locally, like you normally would. For example:
<CodeGroup>
```bash npm
npm run dev
```
```bash pnpm
pnpm run dev
```
```bash yarn
yarn run dev
```
</CodeGroup>
In a **_separate terminal window or tab_** run:
<CodeGroup>
```bash npm
npx @trigger.dev/cli@latest dev --client-id hono-client -p 8787
```
```bash pnpm
pnpm dlx @trigger.dev/cli@latest dev --client-id hono-client -p 8787
```
```bash yarn
yarn dlx @trigger.dev/cli@latest dev --client-id hono-client -p 8787
```
</CodeGroup>
+2 -1
View File
@@ -91,6 +91,7 @@
"documentation/quickstarts/astro",
"documentation/quickstarts/nuxt",
"documentation/quickstarts/sveltekit",
"documentation/quickstarts/hono",
"documentation/quickstarts/fastify"
]
},
@@ -141,7 +142,7 @@
"group": "Guides",
"pages": [
{
"group": "Platforms",
"group": "Frameworks",
"pages": [
"documentation/guides/platforms/nextjs",
"documentation/guides/platforms/express",
+5 -9
View File
@@ -9,8 +9,8 @@ You can define a job by using the `TriggerClient.defineJob` instance method:
<RequestExample>
```ts client.defineJob
client.defineJob({
```ts Example
new Job({
id: "github-integration-on-issue",
name: "GitHub Integration - On Issue",
version: "0.1.0",
@@ -23,11 +23,11 @@ client.defineJob({
await io.logger.info("This is a simple log info message");
return { payload, ctx };
},
});
}).attachToClient(client);
```
```ts notifications
client.defineJob({
new Job({
id: "github-integration-on-issue",
name: "GitHub Integration - On Issue",
version: "0.1.0",
@@ -46,7 +46,7 @@ client.defineJob({
await io.logger.info("This is a simple log info message");
return { payload, ctx };
},
});
}).attachToClient(client);
```
</RequestExample>
@@ -55,10 +55,6 @@ client.defineJob({
## Parameters
<ParamField body="client" type="object" required>
An instance of [TriggerClient](/sdk/triggerclient) that is used to send events to the Trigger API.
</ParamField>
<Snippet file="jobs/options.mdx" />
## Returns
+17 -8
View File
@@ -7,17 +7,14 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "16.x",
"rimraf": "^3.0.2",
"tsup": "7.1.x",
"typescript": "4.9.4"
"tsup": "8.0.1",
"typescript": "^5.3.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -33,5 +30,17 @@
},
"engines": {
"node": ">=16.8.0"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+1
View File
@@ -6,6 +6,7 @@ import { Airtable, AirtableRunTask } from "./index";
import { ListWebhooksResponse, ListWebhooksResponseSchema } from "./schemas";
import { WebhookSource, WebhookTrigger } from "@trigger.dev/sdk/triggers/webhook";
import { registerJobNamespace } from "@trigger.dev/integration-kit/webhooks";
import { Buffer } from "node:buffer";
const WebhookFromSourceSchema = z.union([
z.literal("formSubmission"),
+3 -1
View File
@@ -7,7 +7,9 @@
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"declaration": false,
"declarationMap": false,
+2 -23
View File
@@ -1,24 +1,3 @@
import { defineConfigPackage } from "@trigger.dev/tsup";
import { defineConfig } from "tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+17 -7
View File
@@ -7,18 +7,16 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@octokit/types": "^9.2.3",
"@octokit/webhooks-types": "^6.10.0",
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "18",
"rimraf": "^3.0.2",
"tsup": "^6.5.0"
"tsup": "8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"scripts": {
"clean": "rimraf dist",
@@ -36,5 +34,17 @@
},
"engines": {
"node": ">=16.8.0"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+1
View File
@@ -4,6 +4,7 @@ import type { Logger } from "@trigger.dev/sdk";
import { ExternalSource, HandlerEvent } from "@trigger.dev/sdk";
import { z } from "zod";
import { Github } from "./index";
import { Buffer } from "node:buffer";
type WebhookData = {
id: number;
+3 -1
View File
@@ -7,7 +7,9 @@
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"declaration": false,
"declarationMap": false,
+2 -21
View File
@@ -1,22 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+17 -8
View File
@@ -7,17 +7,14 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "16.x",
"rimraf": "^3.0.2",
"tsup": "7.1.x",
"typescript": "4.9.4"
"tsup": "8.0.1",
"typescript": "^5.3.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -33,5 +30,17 @@
},
"engines": {
"node": ">=16.8.0"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+5 -1
View File
@@ -21,6 +21,7 @@ import { Linear, LinearRunTask, serializeLinearOutput } from "./index";
import { WebhookPayloadSchema } from "./schemas";
import { LinearReturnType } from "./types";
import { queryProperties } from "./utils";
import { Buffer } from "node:buffer";
export class Webhooks {
runTask: LinearRunTask;
@@ -43,7 +44,10 @@ export class Webhooks {
);
}
webhooks(key: IntegrationTaskKey, params?: L.WebhooksQueryVariables): LinearReturnType<Webhook[]> {
webhooks(
key: IntegrationTaskKey,
params?: L.WebhooksQueryVariables
): LinearReturnType<Webhook[]> {
return this.runTask(
key,
async (client, task, io) => {
+3 -1
View File
@@ -7,7 +7,9 @@
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"declaration": false,
"declarationMap": false,
+2 -23
View File
@@ -1,24 +1,3 @@
import { defineConfigPackage } from "@trigger.dev/tsup";
import { defineConfig } from "tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+16 -5
View File
@@ -4,20 +4,31 @@
"description": "The official OpenAI integration for Trigger.dev",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"publishConfig": {
"access": "public"
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
"dist"
],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "18",
"rimraf": "^3.0.2",
"tsup": "^6.5.0",
"typescript": "^4.9.4",
"tsup": "^8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0",
"@types/jest": "^29.5.3",
"jest": "^29.6.2",
"ts-jest": "^29.1.1"
+6 -6
View File
@@ -1,4 +1,4 @@
import { fileFromString } from "@trigger.dev/integration-kit";
import { Buffer } from "node:buffer";
import { IntegrationTaskKey } from "@trigger.dev/sdk";
import OpenAI from "openai";
import { OpenAIRunTask } from "./index";
@@ -9,7 +9,7 @@ import {
createTaskOutputProperties,
handleOpenAIError,
} from "./taskUtils";
import { Uploadable } from "openai/uploads";
import { Uploadable, toFile } from "openai/uploads";
type CreateFileRequest = {
file: string | File | Uploadable;
@@ -42,7 +42,7 @@ export class Files {
let file: Uploadable;
if (typeof params.file === "string") {
file = await fileFromString(params.file, params.fileName ?? "file.txt");
file = await toFile(Buffer.from(params.file), params.fileName ?? "file.txt");
} else {
file = params.file;
}
@@ -81,7 +81,7 @@ export class Files {
let file: Uploadable;
if (typeof params.file === "string") {
file = await fileFromString(params.file, params.fileName ?? "file.txt");
file = await toFile(Buffer.from(params.file), params.fileName ?? "file.txt");
} else {
file = params.file;
}
@@ -242,8 +242,8 @@ export class Files {
return this.runTask(
key,
async (client, task) => {
const file = await fileFromString(
params.examples.map((d) => JSON.stringify(d)).join("\n"),
const file = await toFile(
Buffer.from(params.examples.map((d) => JSON.stringify(d)).join("\n")),
params.fileName
);
+4 -6
View File
@@ -1,4 +1,4 @@
import { FetchRetryOptions, FetchTimeoutOptions, fileFromUrl } from "@trigger.dev/integration-kit";
import { FetchRetryOptions, FetchTimeoutOptions } from "@trigger.dev/integration-kit";
import { IntegrationTaskKey, Prettify } from "@trigger.dev/sdk";
import OpenAI from "openai";
import { OpenAIRunTask } from "./index";
@@ -209,9 +209,8 @@ export class Images {
return this.runTask(
key,
async (client, task) => {
const file =
typeof params.image === "string" ? await fileFromUrl(params.image) : params.image;
const mask = typeof params.mask === "string" ? await fileFromUrl(params.mask) : params.mask;
const file = typeof params.image === "string" ? await fetch(params.image) : params.image;
const mask = typeof params.mask === "string" ? await fetch(params.mask) : params.mask;
const { data, response } = await client.images
.edit(
@@ -288,8 +287,7 @@ export class Images {
return this.runTask(
key,
async (client, task) => {
const file =
typeof params.image === "string" ? await fileFromUrl(params.image) : params.image;
const file = typeof params.image === "string" ? await fetch(params.image) : params.image;
const { data, response } = await client.images
.createVariation(
+3 -1
View File
@@ -7,7 +7,9 @@
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"declaration": false,
"declarationMap": false,
+3 -21
View File
@@ -1,22 +1,4 @@
import { defineConfig } from "tsup";
import { packageOptions } from "@trigger.dev/tsup";
import { defineConfig } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfig({ ...packageOptions, config: "tsconfig.build.json" });
+17 -7
View File
@@ -7,16 +7,14 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "18",
"rimraf": "^3.0.2",
"tsup": "^6.5.0"
"tsup": "8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"scripts": {
"clean": "rimraf dist",
@@ -30,5 +28,17 @@
},
"engines": {
"node": ">=16.8.0"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+3 -1
View File
@@ -7,7 +7,9 @@
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"declaration": false,
"declarationMap": false,
+2 -21
View File
@@ -1,22 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+18 -9
View File
@@ -7,17 +7,14 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "16.x",
"rimraf": "^3.0.2",
"tsup": "7.1.x",
"typescript": "4.9.4"
"tsup": "8.0.1",
"typescript": "^5.3.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -33,5 +30,17 @@
},
"engines": {
"node": ">=16.8.0"
}
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+1 -1
View File
@@ -1,4 +1,4 @@
{
"extends": "@trigger.dev/tsconfig/integration.json",
"include": ["./src/**/*.ts", "tsup.config.ts"],
"include": ["./src/**/*.ts", "tsup.config.ts"]
}
+2 -21
View File
@@ -1,22 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+18 -8
View File
@@ -7,16 +7,14 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "18",
"rimraf": "^3.0.2",
"tsup": "^6.5.0"
"tsup": "8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"scripts": {
"clean": "rimraf dist",
@@ -30,5 +28,17 @@
},
"engines": {
"node": ">=18.0.0"
}
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+3 -1
View File
@@ -7,7 +7,9 @@
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"declaration": false,
"declarationMap": false,
+2 -21
View File
@@ -1,22 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+17 -8
View File
@@ -7,17 +7,14 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "16.x",
"rimraf": "^3.0.2",
"tsup": "7.1.x",
"typescript": "4.9.4"
"tsup": "8.0.1",
"typescript": "^5.3.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -32,5 +29,17 @@
},
"engines": {
"node": ">=16.8.0"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+3 -1
View File
@@ -7,7 +7,9 @@
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"declaration": false,
"declarationMap": false,
+2 -23
View File
@@ -1,24 +1,3 @@
import { defineConfigPackage } from "@trigger.dev/tsup";
import { defineConfig } from "tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+17 -8
View File
@@ -7,17 +7,14 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "16.x",
"rimraf": "^3.0.2",
"tsup": "7.1.x",
"typescript": "4.9.4"
"tsup": "8.0.1",
"typescript": "^5.3.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -33,5 +30,17 @@
},
"engines": {
"node": ">=16.8.0"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+2 -21
View File
@@ -1,22 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+17 -7
View File
@@ -7,16 +7,14 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "18",
"rimraf": "^3.0.2",
"tsup": "^6.5.0"
"tsup": "8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"scripts": {
"clean": "rimraf dist",
@@ -30,5 +28,17 @@
},
"engines": {
"node": ">=16.8.0"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+3 -1
View File
@@ -5,7 +5,9 @@
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"paths": {
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"]
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"declaration": false,
"declarationMap": false,
+2 -21
View File
@@ -1,22 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+17 -8
View File
@@ -7,17 +7,14 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@types/node": "16.x",
"rimraf": "^3.0.2",
"stripe-event-types": "^2.4.0",
"tsup": "7.1.x",
"typescript": "4.9.4"
"tsup": "8.0.1",
"typescript": "^5.3.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -33,5 +30,17 @@
},
"engines": {
"node": ">=16.8.0"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+6 -2
View File
@@ -18,9 +18,13 @@
"sourceMap": true,
"resolveJsonModule": true,
"lib": ["es2019"],
"module": "commonjs",
"module": "node16",
"target": "es2021",
"stripInternal": true
"stripInternal": true,
"paths": {
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
}
},
"include": ["./src/**/*.ts", "tsup.config.ts"],
"exclude": ["node_modules"]
+2 -21
View File
@@ -1,22 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+22 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@trigger.dev/supabase",
"version": "2.2.11",
"version": "2.2.10",
"description": "Trigger.dev integration for @supabase/supabase-js",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -8,16 +8,15 @@
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
"dist"
],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "18.x",
"rimraf": "^3.0.2",
"tsup": "7.1.x",
"typescript": "4.9.4"
"tsup": "8.0.1",
"typescript": "^5.3.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -27,12 +26,24 @@
},
"dependencies": {
"@supabase/supabase-js": "^2.26.0",
"@trigger.dev/integration-kit": "workspace:^2.2.11",
"@trigger.dev/sdk": "workspace:^2.2.11",
"supabase-management-js": "^0.1.4",
"@trigger.dev/integration-kit": "workspace:^2.2.10",
"@trigger.dev/sdk": "workspace:^2.2.10",
"supabase-management-js": "^1.0.0",
"zod": "3.22.3"
},
"engines": {
"node": ">=18.0.0"
}
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
@@ -31,7 +31,7 @@ import {
} from "supabase-management-js";
import { z } from "zod";
import { Prettify, safeParseBody } from "@trigger.dev/integration-kit";
import { randomUUID } from "crypto";
import { randomUUID } from "node:crypto";
import { GenericSchema } from "../database/types";
export type SupabaseManagementIntegrationOptions =
+3 -1
View File
@@ -7,7 +7,9 @@
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"declaration": false,
"declarationMap": false,
+2 -22
View File
@@ -1,23 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
noExternal: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+17 -8
View File
@@ -7,16 +7,13 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/index.js.map"
],
"files": ["dist"],
"devDependencies": {
"@types/node": "16.x",
"rimraf": "^3.0.2",
"tsup": "7.1.x",
"typescript": "4.9.4"
"tsup": "8.0.1",
"typescript": "^5.3.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -32,5 +29,17 @@
},
"engines": {
"node": ">=16.8.0"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"module": "./dist/index.mjs"
}
+6 -2
View File
@@ -7,7 +7,7 @@
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node16",
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
@@ -20,7 +20,11 @@
"lib": ["es2019"],
"module": "commonjs",
"target": "es2021",
"stripInternal": true
"stripInternal": true,
"paths": {
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
}
},
"include": ["./src/**/*.ts", "tsup.config.ts"],
"exclude": ["node_modules"]
+2 -21
View File
@@ -1,22 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "smallest",
},
esbuildPlugins: [],
external: ["http", "https", "util", "events", "tty", "os", "timers"],
},
]);
export default defineConfigPackage;
+2 -1
View File
@@ -71,7 +71,8 @@
},
"pnpm": {
"patchedDependencies": {
"@changesets/assemble-release-plan@5.2.4": "patches/@changesets__assemble-release-plan@5.2.4.patch"
"@changesets/assemble-release-plan@5.2.4": "patches/@changesets__assemble-release-plan@5.2.4.patch",
"tsup@8.0.1": "patches/tsup@8.0.1.patch"
}
}
}
+51
View File
@@ -0,0 +1,51 @@
import { Framework, ProjectInstallOptions } from "..";
import { InstallPackage } from "../../utils/addDependencies";
import { PackageManager } from "../../utils/getUserPkgManager";
import { logger } from "../../utils/logger";
import { readPackageJson } from "../../utils/readPackageJson";
import { standardWatchFilePaths } from "../watchConfig";
import boxen from "boxen";
export class Hono implements Framework {
id = "hono";
name = "Hono.dev";
async isMatch(path: string, packageManager: PackageManager): Promise<boolean> {
//check for the express package
const packageJsonContent = await readPackageJson(path);
if (packageJsonContent?.dependencies?.hono) {
return true;
}
return false;
}
async dependencies(): Promise<InstallPackage[]> {
return [
{ name: "@trigger.dev/sdk", tag: "latest" },
{ name: "@trigger.dev/hono", tag: "latest" },
];
}
possibleEnvFilenames(): string[] {
return [".dev.vars", ".env"];
}
async install(path: string, { typescript, endpointSlug }: ProjectInstallOptions): Promise<void> {}
async postInstall(path: string, options: ProjectInstallOptions): Promise<void> {}
async printInstallationComplete(projectUrl: string): Promise<void> {
logger.info(
boxen(
"Automatic installation isn't currently supported for Hono.dev. \nFollow the steps in our quickstart installation guide: https://trigger.dev/docs/documentation/quickstarts/hono",
{ padding: 1, margin: 1, borderStyle: "double", borderColor: "magenta" }
)
);
}
defaultHostnames = ["127.0.0.1", "localhost", "[::]"];
defaultPorts = [3000, 8000, 80, 8080];
watchFilePaths = standardWatchFilePaths;
watchIgnoreRegex = /(node_modules)/;
}
+2 -1
View File
@@ -2,6 +2,7 @@ import { InstallPackage } from "../utils/addDependencies";
import { PackageManager } from "../utils/getUserPkgManager";
import { Astro } from "./astro";
import { Express } from "./express";
import { Hono } from "./hono";
import { NextJs } from "./nextjs";
import { Remix } from "./remix";
@@ -53,7 +54,7 @@ export interface Framework {
}
/** The order of these matters. The first one that matches the folder will be used, so stricter ones should be first. */
const frameworks: Framework[] = [new NextJs(), new Remix(), new Astro(), new Express()];
const frameworks: Framework[] = [new NextJs(), new Remix(), new Astro(), new Express(), new Hono()];
export const getFramework = async (
path: string,
+1 -2
View File
@@ -1,7 +1,6 @@
import fetch from "./fetchUseProxy";
import { z } from "zod";
import core from "@trigger.dev/core";
const { GetEndpointIndexResponseSchema } = core;
import { GetEndpointIndexResponseSchema } from "@trigger.dev/core";
export type CreateEndpointOptions = {
id: string;
+10 -4
View File
@@ -5,6 +5,7 @@
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"publishConfig": {
"access": "public"
},
@@ -13,8 +14,12 @@
],
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
@@ -33,8 +38,9 @@
"jest": "^29.6.2",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"tsup": "^7.1.0",
"typescript": "^5.1.0"
"tsup": "^8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"engines": {
"node": ">=18.0.0"
+5 -1
View File
@@ -6,7 +6,11 @@
"emitDecoratorMetadata": true,
"declaration": false,
"declarationMap": false,
"types": ["jest"]
"types": ["jest"],
"paths": {
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
}
},
"exclude": ["node_modules"]
}
+5 -19
View File
@@ -1,20 +1,6 @@
import { defineConfig } from "tsup";
import { packageOptions, defineConfig } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
config: "tsconfig.build.json",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "neutral",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
external: ["http", "https", "util", "events", "tty", "os", "timers"],
esbuildPlugins: [],
},
]);
export default defineConfig({
...packageOptions,
config: "tsconfig.build.json",
});
+11 -5
View File
@@ -5,6 +5,7 @@
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"publishConfig": {
"access": "public"
},
@@ -13,8 +14,12 @@
],
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
@@ -38,10 +43,11 @@
"jest": "^29.6.2",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"tsup": "^7.1.0",
"typescript": "^4.9.4"
"tsup": "^8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"engines": {
"node": ">=18.0.0"
}
}
}
+5 -2
View File
@@ -8,6 +8,9 @@
* - `"info"`: Info, Warnings, Errors and essential messages.
* - `"debug"`: Everything.
*/
import { env } from "node:process";
import { Buffer } from "node:buffer";
export type LogLevel = "log" | "error" | "warn" | "info" | "debug";
const logLevels: Array<LogLevel> = ["log", "error", "warn", "info", "debug"];
@@ -27,7 +30,7 @@ export class Logger {
additionalFields?: () => Record<string, unknown>
) {
this.#name = name;
this.#level = logLevels.indexOf((process.env.TRIGGER_LOG_LEVEL ?? level) as LogLevel);
this.#level = logLevels.indexOf((env.TRIGGER_LOG_LEVEL ?? level) as LogLevel);
this.#filteredKeys = filteredKeys;
this.#jsonReplacer = createReplacer(jsonReplacer);
this.#additionalFields = additionalFields ?? (() => ({}));
@@ -169,7 +172,7 @@ function filterKeys(obj: unknown, keys: string[]): any {
}
function prettyPrintBytes(value: unknown): string {
if (process.env.NODE_ENV === "production") {
if (env.NODE_ENV === "production") {
return "skipped size";
}
+5 -1
View File
@@ -7,7 +7,11 @@
"declaration": false,
"declarationMap": false,
"types": ["jest"],
"lib": ["DOM", "DOM.Iterable"]
"lib": ["DOM", "DOM.Iterable"],
"paths": {
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
}
},
"exclude": ["node_modules"]
}
+5 -19
View File
@@ -1,20 +1,6 @@
import { defineConfig } from "tsup";
import { packageOptions, defineConfig } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
config: "tsconfig.build.json",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "neutral",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
external: ["http", "https", "util", "events", "tty", "os", "timers"],
esbuildPlugins: [],
},
]);
export default defineConfig({
...packageOptions,
config: "tsconfig.build.json",
});
@@ -243,7 +243,7 @@ ruleTester.run("no-duplicated-task-keys", rule, {
import { client } from "@/trigger";
// your first job
new Job(client, {
client.defineJob({
id: "example-job",
name: "Example Job",
version: "0.0.1",
@@ -294,7 +294,7 @@ ruleTester.run("no-duplicated-task-keys", rule, {
import { client } from "@/trigger";
// your first job
new Job(client, {
client.defineJob({
id: "example-job",
name: "Example Job",
version: "0.0.1",
+14 -9
View File
@@ -8,13 +8,15 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist"
],
"files": ["dist"],
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
@@ -24,8 +26,10 @@
"@types/debug": "^4.1.7",
"@types/express": "^4.17.13",
"rimraf": "^3.0.2",
"tsup": "^6.5.0",
"tsx": "^3.12.1"
"tsup": "8.0.1",
"tsx": "^3.12.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"scripts": {
"clean": "rimraf dist",
@@ -41,5 +45,6 @@
},
"engines": {
"node": ">=18.0.0"
}
}
},
"module": "./dist/index.mjs"
}
+5 -1
View File
@@ -6,7 +6,11 @@
"emitDecoratorMetadata": true,
"declaration": false,
"declarationMap": false,
"lib": ["DOM"]
"lib": ["DOM"],
"paths": {
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
}
},
"exclude": ["node_modules"]
}
+2 -18
View File
@@ -1,19 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
external: ["http", "https", "util", "events", "tty", "os", "timers"],
esbuildPlugins: [],
},
]);
export default defineConfigPackage;
+49
View File
@@ -0,0 +1,49 @@
{
"name": "@trigger.dev/hono",
"version": "2.2.10",
"description": "A Trigger.dev adapter for Hono.dev",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"publishConfig": {
"access": "public"
},
"files": [
"dist"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"scripts": {
"clean": "rimraf dist",
"build": "npm run clean && npm run build:tsup",
"build:tsup": "tsup --dts-resolve",
"typecheck": "tsc --noEmit"
},
"peerDependencies": {
"hono": "3.x",
"@trigger.dev/sdk": "workspace:^2.2.10"
},
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"rimraf": "^3.0.2",
"tsup": "^8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0",
"hono": "3.10.3",
"@trigger.dev/sdk": "workspace:*"
},
"engines": {
"node": ">=18.0.0"
}
}
+65
View File
@@ -0,0 +1,65 @@
import type { TriggerClient } from "@trigger.dev/sdk";
import type { Env, Hono, HonoRequest, MiddlewareHandler } from "hono";
export function createMiddleware(
client: TriggerClient,
path: string = "/api/trigger"
): MiddlewareHandler {
return async (c, next) => {
if (c.req.path !== path) {
return await next();
}
if (c.req.method === "HEAD") {
return new Response(null, { status: 200 });
}
const request = convertToStandardRequest(c.req);
const response = await client.handleRequest(request);
return new Response(JSON.stringify(response.body), {
status: response.status,
headers: response.headers,
});
};
}
export function addMiddleware<TEnv extends Env>(
app: Hono<TEnv>,
callback: (env: TEnv["Bindings"]) => TriggerClient
) {
app.use("/api/trigger", async (c, next) => {
const client = callback(c.env);
if (c.req.method === "HEAD") {
return new Response(null, { status: 200 });
}
const request = convertToStandardRequest(c.req);
const response = await client.handleRequest(request);
return new Response(JSON.stringify(response.body), {
status: response.status,
headers: response.headers,
});
});
}
function convertToStandardRequest(req: HonoRequest): Request {
const headers: Record<string, string> = {};
const entries = req.raw.headers.entries();
for (const [key, value] of entries) {
headers[key] = value;
}
return new Request(req.raw.url, {
method: req.raw.method,
headers,
body: req.raw.body,
// @ts-ignore
duplex: "half",
});
}
+17
View File
@@ -0,0 +1,17 @@
{
"extends": "@trigger.dev/tsconfig/base.json",
"include": ["./src/**/*.ts", "tsup.config.ts"],
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"declarationMap": false,
"paths": {
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"lib": ["DOM", "DOM.Iterable"],
"downlevelIteration": true
},
"exclude": ["node_modules"]
}
+3
View File
@@ -0,0 +1,3 @@
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfigPackage;
+10 -5
View File
@@ -5,6 +5,7 @@
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"publishConfig": {
"access": "public"
},
@@ -13,8 +14,12 @@
],
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
@@ -23,9 +28,9 @@
"@types/node": "18",
"@types/uuid": "^9.0.0",
"rimraf": "^3.0.2",
"tsup": "^6.5.0",
"tsx": "^3.12.1",
"typescript": "^4.8.4"
"tsup": "^8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"scripts": {
"clean": "rimraf dist",
-20
View File
@@ -1,20 +0,0 @@
import fs, { promises } from "fs";
import path from "path";
import { v4 as uuidv4 } from "uuid";
export async function fileFromString(contents: string | Buffer, fileName: string): Promise<File> {
const directory = path.join("tmp", uuidv4());
await promises.mkdir(directory, { recursive: true });
const filePath = path.join(directory, fileName);
await promises.writeFile(filePath, contents);
return fs.createReadStream(filePath) as unknown as File;
}
export async function fileFromUrl(url: string) {
const response = await fetch(url);
const arrayBuffer = await response.arrayBuffer();
const content = Buffer.from(arrayBuffer);
const fileName = path.basename(url);
return fileFromString(content, fileName);
}
-1
View File
@@ -2,7 +2,6 @@ export * from "./json";
export * from "./webhooks";
export * from "./omit";
export * from "./properties";
export * from "./file";
export * from "./prettify";
export * from "./types";
export * from "./utils";
+1
View File
@@ -1,6 +1,7 @@
// Parses the body of a request
import { safeJsonParse } from "./json";
import { Buffer } from "node:buffer";
// If it's a Buffer, it will be parsed as JSON
export function safeParseBody(body: any) {
+3 -1
View File
@@ -6,7 +6,9 @@
"emitDecoratorMetadata": true,
"paths": {
"@trigger.dev/core/*": ["../core/src/*"],
"@trigger.dev/core": ["../core/src/index"]
"@trigger.dev/core": ["../core/src/index"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
},
"lib": ["DOM", "DOM.Iterable"],
"declaration": false,
+2 -19
View File
@@ -1,20 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
external: ["http", "https", "util", "events", "tty", "os", "timers"],
esbuildPlugins: [],
noExternal: [],
},
]);
export default defineConfigPackage;
+13 -8
View File
@@ -8,13 +8,15 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist"
],
"files": ["dist"],
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
@@ -25,8 +27,10 @@
"@types/express": "^4.17.13",
"fastify": "^4.23.2",
"rimraf": "^3.0.2",
"tsup": "^6.5.0",
"tsx": "^3.12.1"
"tsup": "8.0.1",
"tsx": "^3.12.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"scripts": {
"clean": "rimraf dist",
@@ -44,5 +48,6 @@
},
"engines": {
"node": ">=18.0.0"
}
},
"module": "./dist/index.mjs"
}
+5 -1
View File
@@ -5,7 +5,11 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"declarationMap": false
"declarationMap": false,
"paths": {
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
}
},
"exclude": ["node_modules"]
}
+2 -18
View File
@@ -1,19 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
external: ["http", "https", "util", "events", "tty", "os", "timers"],
esbuildPlugins: [],
},
]);
export default defineConfigPackage;
+14 -10
View File
@@ -8,13 +8,15 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist"
],
"files": ["dist"],
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
@@ -24,11 +26,12 @@
"@types/ws": "^8.5.3",
"next": "^14.0.0",
"rimraf": "^3.0.2",
"tsup": "^6.5.0",
"tsup": "8.0.1",
"tsx": "^3.12.1",
"typescript": "^4.8.4",
"typescript": "^5.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -44,5 +47,6 @@
},
"engines": {
"node": ">=18.0.0"
}
}
},
"module": "./dist/index.mjs"
}
+10 -3
View File
@@ -1,6 +1,5 @@
import type { TriggerClient } from "@trigger.dev/sdk";
import type { NextApiRequest, NextApiResponse } from "next";
import { NextResponse } from "next/server";
export function createPagesRoute(client: TriggerClient) {
const handler = async function handler(req: NextApiRequest, res: NextApiResponse) {
@@ -40,10 +39,18 @@ export function createAppRoute(client: TriggerClient) {
const response = await client.handleRequest(req);
if (!response) {
return NextResponse.json({ error: "Not found" }, { status: 404 });
return new Response(JSON.stringify({ error: "Not found" }), {
status: 404,
headers: {
"Content-Type": "application/json",
},
});
}
return NextResponse.json(response.body, { status: response.status, headers: response.headers });
return new Response(JSON.stringify(response.body), {
status: response.status,
headers: response.headers,
});
};
return {
+3 -1
View File
@@ -9,7 +9,9 @@
"lib": ["DOM", "DOM.Iterable"],
"paths": {
"@trigger.dev/sdk": ["../trigger-sdk/src/index"],
"@trigger.dev/sdk/*": ["../trigger-sdk/src/*"]
"@trigger.dev/sdk/*": ["../trigger-sdk/src/*"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
}
},
"exclude": ["node_modules"]
+2 -18
View File
@@ -1,19 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
external: ["http", "https", "util", "events", "tty", "os", "timers"],
esbuildPlugins: [],
},
]);
export default defineConfigPackage;
+12 -8
View File
@@ -8,13 +8,15 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist"
],
"files": ["dist"],
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
@@ -24,9 +26,10 @@
"@types/debug": "^4.1.7",
"@types/ws": "^8.5.3",
"rimraf": "^3.0.2",
"tsup": "^6.5.0",
"tsup": "8.0.1",
"tsx": "^3.12.1",
"typescript": "^4.8.4"
"typescript": "^5.3.0",
"@trigger.dev/tsup": "workspace:*"
},
"scripts": {
"clean": "rimraf dist",
@@ -42,5 +45,6 @@
},
"engines": {
"node": ">=18.0.0"
}
},
"module": "./dist/index.mjs"
}
+3 -1
View File
@@ -9,7 +9,9 @@
"lib": ["DOM", "DOM.Iterable"],
"paths": {
"@trigger.dev/sdk": ["../trigger-sdk/src/index"],
"@trigger.dev/sdk/*": ["../trigger-sdk/src/*"]
"@trigger.dev/sdk/*": ["../trigger-sdk/src/*"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
}
},
"exclude": ["node_modules"]
+2 -18
View File
@@ -1,19 +1,3 @@
import { defineConfig } from "tsup";
import { defineConfigPackage } from "@trigger.dev/tsup";
export default defineConfig([
{
name: "main",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs"],
legacyOutput: true,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
external: ["http", "https", "util", "events", "tty", "os", "timers"],
esbuildPlugins: [],
},
]);
export default defineConfigPackage;
+12 -7
View File
@@ -9,13 +9,15 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist"
],
"files": ["dist"],
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
@@ -25,7 +27,9 @@
"@types/debug": "^4.1.7",
"@types/ws": "^8.5.3",
"rimraf": "^3.0.2",
"tsup": "^6.5.0"
"tsup": "8.0.1",
"@trigger.dev/tsup": "workspace:*",
"typescript": "^5.3.0"
},
"scripts": {
"clean": "rimraf dist",
@@ -40,5 +44,6 @@
},
"engines": {
"node": ">=18.0.0"
}
},
"module": "./dist/index.mjs"
}
+4 -2
View File
@@ -9,9 +9,11 @@
"lib": ["DOM", "DOM.Iterable"],
"paths": {
"@trigger.dev/sdk": ["../trigger-sdk/src/index"],
"@trigger.dev/sdk/*": ["../trigger-sdk/src/*"],
"@trigger.dev/sdk/*": ["../trigger-sdk/src/*"],
"@trigger.dev/core": ["../core/src/index"],
"@trigger.dev/core/*": ["../core/src/*"]
"@trigger.dev/core/*": ["../core/src/*"],
"@trigger.dev/tsup/*": ["../../config-packages/tsup/src/*"],
"@trigger.dev/tsup": ["../../config-packages/tsup/src/index"]
}
},
"exclude": ["node_modules"]

Some files were not shown because too many files have changed in this diff Show More