+
+
Original
+
{gridImages.map((image, index) => (
-
-
-
- {image.status === "completed" ? (
-
- ) : (
-
+
+
Style {index + 1}
+
+
+
+ {image.status === "completed" ? (
+
+ ) : (
+
+
+
Model: {image.message}
+
+ )}
+
+ {image.status === "completed" && (
+
+ {image.caption}
+
)}
-
- {image.status === "completed" && (
-
{image.caption}
- )}
-
-
+
+
+
))}
diff --git a/references/nextjs-realtime/src/trigger/images.ts b/references/nextjs-realtime/src/trigger/images.ts
index 8e97f3dca5..b3a47e6f53 100644
--- a/references/nextjs-realtime/src/trigger/images.ts
+++ b/references/nextjs-realtime/src/trigger/images.ts
@@ -17,12 +17,9 @@ export const handleUpload = schemaTask({
const results = await runFalModel.batchTriggerAndWait([
{
payload: {
- model: "fal-ai/image-preprocessors/canny",
+ model: "fal-ai/image-preprocessors/lineart",
url: file.url,
- input: {
- low_threshold: 100,
- high_threshold: 200,
- },
+ input: {},
},
options: {
tags: ctx.run.tags,
@@ -30,9 +27,16 @@ export const handleUpload = schemaTask({
},
{
payload: {
- model: "fal-ai/aura-sr",
+ model: "fal-ai/omni-zero",
url: file.url,
- input: {},
+ input: {
+ prompt: "Turn the image into a cartoon",
+ image_url: file.url,
+ composition_image_url: file.url,
+ style_image_url:
+ "https://storage.googleapis.com/falserverless/model_tests/omni_zero/style.jpg",
+ identity_image_url: file.url,
+ },
},
options: { tags: ctx.run.tags },
},
diff --git a/references/prisma-catalog/package.json b/references/prisma-catalog/package.json
deleted file mode 100644
index 74f9f3943c..0000000000
--- a/references/prisma-catalog/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "references-prisma-catalog",
- "private": true,
- "type": "module",
- "devDependencies": {
- "trigger.dev": "workspace:*",
- "@trigger.dev/build": "workspace:*",
- "typescript": "^5.5.4",
- "prisma": "5.19.0"
- },
- "dependencies": {
- "@trigger.dev/sdk": "workspace:*",
- "@prisma/client": "5.19.0"
- },
- "scripts": {
- "generate:prisma": "prisma generate --sql"
- }
-}
\ No newline at end of file
diff --git a/references/prisma-catalog/prisma/migrations/20240919122925_add_initial_schema/migration.sql b/references/prisma-catalog/prisma/migrations/20240919122925_add_initial_schema/migration.sql
deleted file mode 100644
index 4af85373f9..0000000000
--- a/references/prisma-catalog/prisma/migrations/20240919122925_add_initial_schema/migration.sql
+++ /dev/null
@@ -1,20 +0,0 @@
--- CreateTable
-CREATE TABLE "User" (
- "id" SERIAL NOT NULL,
- "name" TEXT NOT NULL,
-
- CONSTRAINT "User_pkey" PRIMARY KEY ("id")
-);
-
--- CreateTable
-CREATE TABLE "Post" (
- "id" SERIAL NOT NULL,
- "title" TEXT NOT NULL,
- "content" TEXT NOT NULL,
- "authorId" INTEGER NOT NULL,
-
- CONSTRAINT "Post_pkey" PRIMARY KEY ("id")
-);
-
--- AddForeignKey
-ALTER TABLE "Post" ADD CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/references/prisma-catalog/prisma/migrations/migration_lock.toml b/references/prisma-catalog/prisma/migrations/migration_lock.toml
deleted file mode 100644
index fbffa92c2b..0000000000
--- a/references/prisma-catalog/prisma/migrations/migration_lock.toml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Please do not edit this file manually
-# It should be added in your version-control system (i.e. Git)
-provider = "postgresql"
\ No newline at end of file
diff --git a/references/prisma-catalog/prisma/schema.prisma b/references/prisma-catalog/prisma/schema.prisma
deleted file mode 100644
index b05278b729..0000000000
--- a/references/prisma-catalog/prisma/schema.prisma
+++ /dev/null
@@ -1,26 +0,0 @@
-generator client {
- provider = "prisma-client-js"
- previewFeatures = ["typedSql"]
-}
-
-datasource db {
- provider = "postgresql"
- url = env("DATABASE_URL")
- directUrl = env("DIRECT_DATABASE_URL")
-}
-
-// user.prisma
-model User {
- id Int @id @default(autoincrement())
- name String
- posts Post[]
-}
-
-// post.prisma
-model Post {
- id Int @id @default(autoincrement())
- title String
- content String
- authorId Int
- author User @relation(fields: [authorId], references: [id])
-}
diff --git a/references/prisma-catalog/prisma/sql/getUsersWithPosts.sql b/references/prisma-catalog/prisma/sql/getUsersWithPosts.sql
deleted file mode 100644
index 8f0cb3576d..0000000000
--- a/references/prisma-catalog/prisma/sql/getUsersWithPosts.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-SELECT
- u.id,
- u.name,
- COUNT(p.id) as "postCount"
-FROM
- "User" u
- LEFT JOIN "Post" p ON u.id = p."authorId"
-GROUP BY
- u.id,
- u.name;
\ No newline at end of file
diff --git a/references/prisma-catalog/src/db.ts b/references/prisma-catalog/src/db.ts
deleted file mode 100644
index 5e029ca062..0000000000
--- a/references/prisma-catalog/src/db.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { PrismaClient } from "@prisma/client";
-import { getUsersWithPosts } from "@prisma/client/sql";
-
-export const prisma = new PrismaClient();
-
-export { getUsersWithPosts };
diff --git a/references/prisma-catalog/src/trigger/dbTasks.ts b/references/prisma-catalog/src/trigger/dbTasks.ts
deleted file mode 100644
index 7edb466019..0000000000
--- a/references/prisma-catalog/src/trigger/dbTasks.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { getUsersWithPosts, prisma } from "../db.js";
-import { logger, task } from "@trigger.dev/sdk/v3";
-
-export const prismaTask = task({
- id: "prisma-task",
- run: async () => {
- const users = await prisma.user.findMany();
-
- await prisma.user.create({
- data: {
- name: "Alice",
- },
- });
-
- const usersWithPosts = await prisma.$queryRawTyped(getUsersWithPosts());
-
- logger.info("Users with posts", { usersWithPosts });
-
- return users;
- },
-});
diff --git a/references/prisma-catalog/trigger.config.ts b/references/prisma-catalog/trigger.config.ts
deleted file mode 100644
index 1bbf0eb2cd..0000000000
--- a/references/prisma-catalog/trigger.config.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { prismaExtension } from "@trigger.dev/build/extensions/prisma";
-import { defineConfig } from "@trigger.dev/sdk/v3";
-
-export default defineConfig({
- runtime: "node",
- project: "proj_mpzmrzygzbvmfjnnpcsk",
- retries: {
- enabledInDev: false,
- default: {
- maxAttempts: 3,
- minTimeoutInMs: 5_000,
- maxTimeoutInMs: 30_000,
- factor: 2,
- randomize: true,
- },
- },
- build: {
- extensions: [
- prismaExtension({
- schema: "prisma/schema.prisma",
- directUrlEnvVarName: "DIRECT_DATABASE_URL",
- typedSql: true,
- }),
- ],
- },
-});
diff --git a/references/prisma-catalog/tsconfig.json b/references/prisma-catalog/tsconfig.json
deleted file mode 100644
index 9a5ee0b9d6..0000000000
--- a/references/prisma-catalog/tsconfig.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "compilerOptions": {
- "target": "ES2023",
- "module": "Node16",
- "moduleResolution": "Node16",
- "esModuleInterop": true,
- "strict": true,
- "skipLibCheck": true,
- "customConditions": ["@triggerdotdev/source"],
- "jsx": "preserve",
- "lib": ["DOM", "DOM.Iterable"],
- "noEmit": true
- },
- "include": ["./src/**/*.ts", "trigger.config.ts"]
-}
diff --git a/references/v3-catalog/package.json b/references/v3-catalog/package.json
index ceedc89f3f..3e9896329d 100644
--- a/references/v3-catalog/package.json
+++ b/references/v3-catalog/package.json
@@ -16,18 +16,22 @@
"generate:prisma": "prisma generate --sql"
},
"dependencies": {
+ "@effect/schema": "^0.75.5",
"@infisical/sdk": "^2.1.9",
"@opentelemetry/api": "1.4.1",
"@prisma/client": "5.19.0",
"@react-email/components": "0.0.24",
"@react-email/render": "1.0.1",
"@sentry/esbuild-plugin": "^2.22.2",
+ "@sinclair/typebox": "^0.33.17",
"@sindresorhus/slugify": "^2.2.1",
"@t3-oss/env-core": "^0.11.0",
"@t3-oss/env-nextjs": "^0.10.1",
"@traceloop/instrumentation-openai": "^0.10.0",
"@trigger.dev/sdk": "workspace:*",
+ "@typeschema/typebox": "^0.14.0",
"ai": "^3.3.24",
+ "arktype": "2.0.0-rc.17",
"dotenv": "^16.4.5",
"email-reply-parser": "^1.8.0",
"execa": "^8.0.1",
@@ -41,11 +45,15 @@
"react": "19.0.0-rc.0",
"react-email": "^3.0.1",
"reflect-metadata": "^0.1.13",
+ "runtypes": "^6.7.0",
"server-only": "^0.0.1",
"stripe": "^12.14.0",
+ "superstruct": "^2.0.2",
"typeorm": "^0.3.20",
+ "valibot": "^0.42.1",
"wrangler": "3.70.0",
"yt-dlp-wrap": "^2.3.12",
+ "yup": "^1.4.0",
"zod": "3.22.3"
},
"devDependencies": {
diff --git a/references/v3-catalog/src/clientUsage.ts b/references/v3-catalog/src/clientUsage.ts
index 936583524a..9cb0b38e1b 100644
--- a/references/v3-catalog/src/clientUsage.ts
+++ b/references/v3-catalog/src/clientUsage.ts
@@ -1,5 +1,5 @@
import { auth, runs, tasks } from "@trigger.dev/sdk/v3";
-import type { task1, task2 } from "./trigger/taskTypes.js";
+import type { task1, zodTask } from "./trigger/taskTypes.js";
import { randomUUID } from "crypto";
async function main() {
@@ -22,8 +22,18 @@ async function main() {
console.log("Auto JWT", anyHandle.publicAccessToken);
+ const publicToken = await auth.createPublicToken({
+ scopes: {
+ read: {
+ runs: true,
+ },
+ },
+ });
+
await auth.withAuth({ accessToken: anyHandle.publicAccessToken }, async () => {
- const subscription = runs.subscribeToRunsWithTag
(`user:${userId}`);
+ const subscription = runs.subscribeToRunsWithTag(
+ `user:${userId}`
+ );
for await (const run of subscription) {
switch (run.taskIdentifier) {
@@ -33,7 +43,7 @@ async function main() {
console.log("Payload:", run.payload);
break;
}
- case "types/task-2": {
+ case "types/zod": {
console.log("Run update:", run);
console.log("Output:", run.output);
console.log("Payload:", run.payload);
diff --git a/references/v3-catalog/src/trigger/taskTypes.ts b/references/v3-catalog/src/trigger/taskTypes.ts
index 28aafa068d..06e0104a55 100644
--- a/references/v3-catalog/src/trigger/taskTypes.ts
+++ b/references/v3-catalog/src/trigger/taskTypes.ts
@@ -1,4 +1,4 @@
-import { task, schemaTask } from "@trigger.dev/sdk/v3";
+import { task, schemaTask, type TaskPayload } from "@trigger.dev/sdk/v3";
import { z } from "zod";
export const task1 = task({
@@ -8,16 +8,143 @@ export const task1 = task({
},
});
-const Task2Payload = z.object({
- bar: z.string(),
+export const zodTask = schemaTask({
+ id: "types/zod",
+ schema: z.object({
+ bar: z.string(),
+ baz: z.string().default("foo"),
+ }),
+ run: async (payload) => {
+ console.log(payload.bar, payload.baz);
+ },
+});
+
+type ZodPayload = TaskPayload;
+
+import * as yup from "yup";
+
+export const yupTask = schemaTask({
+ id: "types/yup",
+ schema: yup.object({
+ bar: yup.string().required(),
+ baz: yup.string().default("foo"),
+ }),
+ run: async (payload) => {
+ console.log(payload.bar, payload.baz);
+ },
+});
+
+type YupPayload = TaskPayload;
+
+import { object, string } from "superstruct";
+
+export const superstructTask = schemaTask({
+ id: "types/superstruct",
+ schema: object({
+ bar: string(),
+ baz: string(),
+ }),
+ run: async (payload) => {
+ console.log(payload.bar, payload.baz);
+ },
+});
+
+type SuperstructPayload = TaskPayload;
+
+import { type } from "arktype";
+
+export const arktypeTask = schemaTask({
+ id: "types/arktype",
+ schema: type({
+ bar: "string",
+ baz: "string",
+ }).assert,
+ run: async (payload) => {
+ console.log(payload.bar, payload.baz);
+ },
+});
+
+type ArktypePayload = TaskPayload;
+
+import * as Schema from "@effect/schema/Schema";
+
+const effectSchemaParser = Schema.decodeUnknownSync(
+ Schema.Struct({ bar: Schema.String, baz: Schema.String })
+);
+
+export const effectTask = schemaTask({
+ id: "types/effect",
+ schema: effectSchemaParser,
+ run: async (payload) => {
+ console.log(payload.bar, payload.baz);
+ },
+});
+
+type EffectPayload = TaskPayload;
+
+import * as T from "runtypes";
+
+export const runtypesTask = schemaTask({
+ id: "types/runtypes",
+ schema: T.Record({
+ bar: T.String,
+ baz: T.String,
+ }),
+ run: async (payload) => {
+ console.log(payload.bar, payload.baz);
+ },
+});
+
+type RuntypesPayload = TaskPayload;
+
+import * as v from "valibot";
+
+const valibotParser = v.parser(
+ v.object({
+ bar: v.string(),
+ baz: v.string(),
+ })
+);
+
+export const valibotTask = schemaTask({
+ id: "types/valibot",
+ schema: valibotParser,
+ run: async (payload) => {
+ console.log(payload.bar, payload.baz);
+ },
+});
+
+import { Type } from "@sinclair/typebox";
+import { wrap } from "@typeschema/typebox";
+
+export const typeboxTask = schemaTask({
+ id: "types/typebox",
+ schema: wrap(
+ Type.Object({
+ bar: Type.String(),
+ baz: Type.String(),
+ })
+ ),
+ run: async (payload) => {
+ console.log(payload.bar, payload.baz);
+ },
});
-export const task2 = schemaTask({
- id: "types/task-2",
- schema: Task2Payload,
- run: async (payload, { ctx }) => {
- console.log(ctx.run.idempotencyKey);
+export const customParserTask = schemaTask({
+ id: "types/custom-parser",
+ schema: (data: unknown) => {
+ // This is a custom parser, and should do actual parsing (not just casting)
+ if (typeof data !== "object") {
+ throw new Error("Invalid data");
+ }
+
+ const { bar, baz } = data as { bar: string; baz: string };
- return { goodbye: "world" as const };
+ return { bar, baz };
+ },
+ run: async (payload) => {
+ console.log(payload.bar, payload.baz);
},
});
+
+type CustomParserPayload = TaskPayload;