---
title: "Extensions Layer"
description: "The Extensions Layer refers to a set of custom build extensions designed to integrate specific project dependencies and workspace packages into the @trigger.dev/build process. These extensions cust..."
last_updated: "2026-05-06T07:29:41.642464+00:00"
canonical_url: "https://www.doc0.dev/docs/49c89830-117b-4def-8edc-b5bcc50766e0/technical/section-2/extensions-layer"
---

<details>
<summary>Relevant source files</summary>

The following files were used as context for generating this wiki page:

- [apps/api/customPrismaExtension.ts](https://github.com/blade47/comp/blob/main/apps/api/customPrismaExtension.ts)
- [apps/api/emailExtension.ts](https://github.com/blade47/comp/blob/main/apps/api/emailExtension.ts)
- [apps/api/integrationPlatformExtension.ts](https://github.com/blade47/comp/blob/main/apps/api/integrationPlatformExtension.ts)
</details>

The Extensions Layer refers to a set of custom build extensions designed to integrate specific project dependencies and workspace packages into the `@trigger.dev/build` process. These extensions customize how certain modules are handled during the build, ensuring they are correctly resolved, generated, and bundled for deployment or local development.

This layer addresses challenges such as managing Prisma client generation, resolving imports for internal workspace packages, and copying necessary build artifacts. By using the `@trigger.dev/build` `BuildExtension` interface, these extensions hook into various stages of the build lifecycle, like `onBuildStart` and `onBuildComplete`, to perform specialized tasks.

## Prisma Extension

The `PrismaExtension` is responsible for integrating Prisma into the build process, particularly for the `@trycompai/db` package. Its primary goal is to ensure that the Prisma client is correctly generated and included in the deployment bundle, and that Prisma-related modules are externalized where appropriate.

### Purpose and Configuration

The extension handles the resolution of the `schema.prisma` file, the local generation of the Prisma client during development, and the copying and generation of the client for deployment. It can be configured with various options to control its behavior.

<Callout title="Important" variant="info">
This extension is crucial for projects using Prisma, especially when the schema is part of a shared workspace package like `@trycompai/db`, as it ensures the Prisma client is available and correctly configured in both development and deployment environments.
</Callout>

**`PrismaExtensionOptions`**

| Option                 | Type      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <p>The following files were used as context for generating this<br>this.moduleExternals = [<br>      '@prisma/client',<br>      '@prisma/client',<br>      '@trycompai/db', // Add the published package to externals<br>    ];<br>  }<br><br>  externalsForTarget(target: any) {<br>    if (target === 'dev') {<br>      return [];<br>    }<br>    return this.moduleExternals;<br>  }<br><br>  async onBuildStart(context: BuildContext) {<br>    if (context.target === 'dev') {<br>      return;<br>    }<br><br>    const resolution = this.tryResolveSchemaPath(context as ExtendedBuildContext);<br><br>    if (!resolution.path) {<br>      context.logger.debug(<br>        'Prisma schema not found during build start, likely before dependencies are installed.',<br>        { searched: resolution.searched },<br>      );<br>      return;<br>    }<br><br>    this._resolvedSchemaPath = resolution.path;<br>    context.logger.debug(`Resolved prisma schema to ${resolution.path}`);<br>    await this.ensureLocalPrismaClient(context as ExtendedBuildContext, resolution.path);<br>  }<br><br>  async onBuildComplete(context: BuildContext, manifest: BuildManifest) {<br>    if (context.target === 'dev') {<br>      return;<br>    }<br><br>    if (!this._resolvedSchemaPath || !existsSync(this._resolvedSchemaPath)) {<br>      const resolution = this.tryResolveSchemaPath(context as ExtendedBuildContext);<br><br>      if (!resolution.path) {<br>        throw new Error(<br>          [<br>            'PrismaExtension could not find the prisma schema. Make sure @trycompai/db is installed',<br>            `with version ${this.options.dbPackageVersion || 'latest'} and that its dist files are built.`,<br>            'Searched the following locations:',<br>            ...resolution.searched.map((candidate) => ` - ${candidate}`),<br>          ].join('\n'),<br>        );<br>      }<br><br>      this._resolvedSchemaPath = resolution.path;<br>    }<br><br>    assert(this._resolvedSchemaPath, 'Resolved schema path is not set');<br>    const schemaPath = this._resolvedSchemaPath;<br><br>    await this.ensureLocalPrismaClient(context as ExtendedBuildContext, schemaPath);<br><br>    context.logger.debug('Looking for @prisma/client in the externals', {<br>      externals: manifest.externals,<br>    });<br><br>    const prismaExternal = manifest.externals?.find(<br>      (external) => external.name === '@prisma/client',<br>    );<br>    const version = prismaExternal?.version ?? this.options.version;<br><br>    if (!version) {<br>      throw new Error(<br>        `PrismaExtension could not determine the version of @prisma/client. It's possible that the @prisma/client was not used in the project. If this isn't the case, please provide a version in the PrismaExtension options.`,<br>      );<br>    }<br><br>    context.logger.debug(<br>      `PrismaExtension is generating the Prisma client for version ${version} from @trycompai/db package`,<br>    );<br><br>    const commands: string[] = [];<br>    const env: Record<string, string | undefined> = {};<br><br>    // Copy the prisma schema from the published package to the build output path<br>    const schemaDestinationPath = join(manifest.outputPath, 'prisma', 'schema.prisma');<br>    const schemaDestinationDir = dirname(schemaDestinationPath);<br>    context.logger.debug(<br>      `Copying the prisma schema from ${schemaPath} to ${schemaDestinationPath}`,<br>    );<br>    await mkdir(schemaDestinationDir, { recursive: true });<br>    await cp(schemaPath, schemaDestinationPath);<br><br>    // Add prisma generate command to generate the client from the copied schema<br>    commands.push(<br>      `${binaryForRuntime(manifest.runtime)} node_modules/prisma/build/index.js generate --schema=./prisma/schema.prisma`,<br>    );<br><br>    // Only handle migrations if requested<br>    if (this.options.migrate) {<br>      context.logger.debug(<br>        'Migration support not implemented for published package - please handle migrations separately',<br>      );<br>      // You could add migration commands here if needed<br>      // commands.push(`${binaryForRuntime(manifest.runtime)} npx prisma migrate deploy`);<br>    }<br><br>    // Set up environment variables<br>    env.DATABASE_URL = manifest.deploy.env?.DATABASE_URL;<br><br>    if (this.options.directUrlEnvVarName) {<br>      env[this.options.directUrlEnvVarName] =<br>        manifest.deploy.env?.[this.options.directUrlEnvVarName] ??<br>        process.env[this.options.directUrlEnvVarName];<br>      if (!env[this.options.directUrlEnvVarName]) {<br>        context.logger.warn(<br>          `prismaExtension could not resolve the ${this.options.directUrlEnvVarName} environment variable. Make sure you add it to your environment variables or provide it as an environment variable to the deploy CLI command. See our docs for more info: https://trigger.dev/docs/deploy-environment-variables`,<br>        );<br>      }<br>    } else {<br>      env.DIRECT_URL = manifest.deploy.env?.DIRECT_URL;<br>      env.DIRECT_DATABASE_URL = manifest.deploy.env?.DIRECT_DATABASE_URL;<br>    }<br><br>    if (!env.DATABASE_URL) {<br>      context.logger.warn(<br>        'prismaExtension could not resolve the DATABASE_URL environment variable. Make sure you add it to your environment variables. See our docs for more info: https://trigger.dev/docs/deploy-environment-variables',<br>      );<br>    }<br><br>    context.logger.debug('Adding the prisma layer with the following commands', {<br>      commands,<br>      env,<br>      dependencies: {<br>        prisma: version,<br>        '@trycompai/db': this.options.dbPackageVersion || 'latest',<br>      },<br>    });<br><br>    context.addLayer({<br>      id: 'prisma',<br>      commands,<br>      dependencies: {<br>        prisma: version,<br>        '@trycompai/db': this.options.dbPackageVersion || 'latest',<br>      },<br>      build: {<br>        env,<br>      },<br>    });<br>  }<br><br>  private async ensureLocalPrismaClient(<br>    context: ExtendedBuildContext,<br>    schemaSourcePath: string,<br>  ): Promise<void> {<br>    const schemaDir = resolve(context.workingDir, 'prisma');<br>    const schemaDestinationPath = resolve(schemaDir, 'schema.prisma');<br><br>    await mkdir(schemaDir, { recursive: true });<br>    await cp(schemaSourcePath, schemaDestinationPath);<br><br>    const clientEntryPoint = resolve(context.workingDir, 'node_modules/.prisma/client/default.js');<br><br>    if (existsSync(clientEntryPoint) && !process.env.TRIGGER_PRISMA_FORCE_GENERATE) {<br>      context.logger.debug('Prisma client already generated locally, skipping regenerate.');<br>      return;<br>    }<br><br>    const prismaBinary = this.resolvePrismaBinary(context.workingDir);<br><br>    if (!prismaBinary) {<br>      context.logger.debug(<br>        'Prisma CLI not available yet, skipping local generate until install finishes.',<br>      );<br>      return;<br>    }<br><br>    context.logger.log('Prisma client missing. Generating before Trigger indexing.');<br>    await this.runPrismaGenerate(context, prismaBinary, schemaDestinationPath);<br>  }<br><br>  private runPrismaGenerate(<br>    context: ExtendedBuildContext,<br>    prismaBinary: string,<br>    schemaPath: string,<br>  ): Promise<void> {<br>    return new Promise((resolvePromise, rejectPromise) => {<br>      const child = spawn(prismaBinary, ['generate', `--schema=${schemaPath}`], {<br>        cwd: context.workingDir,<br>        env: {<br>          ...process.env,<br>          PRISMA_HIDE_UPDATE_MESSAGE: '1',<br>        },<br>      });<br><br>      child.stdout?.on('data', (data: Buffer) => {<br>        context.logger.debug(data.toString().trim());<br>      });<br><br>      child.stderr?.on('data', (data: Buffer) => {<br>        context.logger.warn(data.toString().trim());<br>      });<br><br>      child.on('error', (error) => {<br>        rejectPromise(error);<br>      });<br><br>      child.on('close', (code) => {<br>        if (code === 0) {<br>          resolvePromise();<br>        } else {<br>          rejectPromise(new Error(`prisma generate exited with code ${code}`));<br>        }<br>      });<br>    });<br>  }<br><br>  private resolvePrismaBinary(workingDir: string): string | undefined {<br>    const binDir = resolve(workingDir, 'node_modules', '.bin');<br>    const executable = process.platform === 'win32' ? 'prisma.cmd' : 'prisma';<br>    const binaryPath = resolve(binDir, executable);<br><br>    if (!existsSync(binaryPath)) {<br>      return undefined;<br>    }<br><br>    return binaryPath;<br>  }<br><br>  private tryResolveSchemaPath(context: ExtendedBuildContext): SchemaResolution {<br>    const candidates = this.buildSchemaCandidates(context);<br>    const path = candidates.find((candidate) => existsSync(candidate));<br>    return { path, searched: candidates };<br>  }<br><br>  private buildSchemaCandidates(context: ExtendedBuildContext): string[] {<br>    const candidates = new Set<string>();<br><br>    const addNodeModuleCandidates = (start: string | undefined) => {<br>      if (!start) {<br>        return;<br>      }<br><br>      let current = start;<br>      while (true) {<br>        candidates.add(resolve(current, 'node_modules/@trycompai/db/dist/schema.prisma'));<br>        const parent = dirname(current);<br>        if (parent === current) {<br>          break;<br>        }<br>        current = parent;<br>      }<br>    };<br><br>    addNodeModuleCandidates(context.workingDir);<br>    addNodeModuleCandidates(context.workspaceDir);<br><br>    candidates.add(resolve(context.workingDir, '../../packages/db/dist/schema.prisma'));<br>    candidates.add(resolve(context.workingDir, '../packages/db/dist/schema.prisma'));<br><br>    return Array.from(candidates);<br>  }<br>}<br><br><br><br><br>--- File: apps/api/emailExtension.ts ---<br>import type {<br>  BuildContext,<br>  BuildExtension,<br>  BuildManifest,<br>} from '@trigger.dev/build';<br>import type { Plugin } from 'esbuild';<br>import { existsSync } from 'node:fs';<br>import { cp, mkdir } from 'node:fs/promises';<br>import { resolve } from 'node:path';<br><br>const PACKAGE_NAME = '@trycompai/email';<br><br>/**<br> * Custom Trigger.dev build extension for @trycompai/email workspace package.<br> *<br> * Since @trycompai/email is a workspace package (not published to npm),<br> * we need to:<br> * 1. Add an esbuild plugin to resolve the import path during build<br> * 2. Copy the built dist files into the trigger.dev deployment<br> */<br>export function emailExtension(): EmailExtension {<br>  return new EmailExtension();<br>}<br><br>class EmailExtension implements BuildExtension {<br>  public readonly name = 'EmailExtension';<br>  private _packagePath: string | undefined;<br><br>  async onBuildStart(context: BuildContext) {<br>    if (context.target === 'dev') {<br>      return;<br>    }<br><br>    this._packagePath = this.findPackageRoot(context.workingDir);<br><br>    if (!this._packagePath) {<br>      throw new Error(<br>        [<br>          `EmailExtension could not find ${PACKAGE_NAME}.`,<br>          'Make sure the package is built (run `bun run build` in packages/email).',<br>        ].join('\n'),<br>      );<br>    }<br><br>    context.logger.debug(`Found email package at ${this._packagePath}`);<br><br>    const packagePath = this._packagePath;<br>    const resolvePlugin: Plugin = {<br>      name: 'resolve-email',<br>      setup(build) {<br>        build.onResolve({ filter: /^@trycompai\/email$/ }, () => {<br>          return {<br>            path: resolve(packagePath, 'dist/index.js'),<br>          };<br>        });<br><br>        build.onResolve(<br>          { filter: /^@trycompai\/email\// },<br>          (args) => {<br>            const subpath = args.path.replace(`${PACKAGE_NAME}/`, '');<br>            return {<br>              path: resolve(packagePath, 'dist', `${subpath}/index.js`),<br>            };<br>          },<br>        );<br>      },<br>    };<br><br>    context.registerPlugin(resolvePlugin);<br>  }<br><br>  async onBuildComplete(context: BuildContext, manifest: BuildManifest) {<br>    if (context.target === 'dev') {<br>      return;<br>    }<br><br>    const packagePath = this._packagePath;<br>    if (!packagePath) {<br>      return;<br>    }<br><br>    const packageDistPath = resolve(packagePath, 'dist');<br><br>    const destPath = resolve(<br>      manifest.outputPath,<br>      'node_modules/@trycompai/email',<br>    );<br>    const destDistPath = resolve(destPath, 'dist');<br><br>    await mkdir(destDistPath, { recursive: true });<br><br>    await cp(packageDistPath, destDistPath, { recursive: true });<br><br>    const packageJsonPath = resolve(packagePath, 'package.json');<br>    if (existsSync(packageJsonPath)) {<br>      await cp(packageJsonPath, resolve(destPath, 'package.json'));<br>    }<br><br>    context.logger.log(<br>      'Copied @trycompai/email to deployment bundle',<br>    );<br>  }<br><br>  private findPackageRoot(workingDir: string): string | undefined {<br>    const candidates = [<br>      resolve(workingDir, '../../packages/email'),<br>      resolve(workingDir, '../packages/email'),<br>    ];<br><br>    for (const candidate of candidates) {<br>      if (<br>        existsSync(candidate) &&<br>        existsSync(resolve(candidate, 'dist/index.js'))<br>      ) {<br>        return candidate;<br>      }<br>    }<br><br>    return undefined;<br>  }<br>}<br><br><br>--- File: apps/api/integrationPlatformExtension.ts ---<br>import type {<br>  BuildContext,<br>  BuildExtension,<br>  BuildManifest,<br>} from '@trigger.dev/build';<br>import type { Plugin } from 'esbuild';<br>import { existsSync } from 'node:fs';<br>import { cp, mkdir } from 'node:fs/promises';<br>import { dirname, resolve } from 'node:path';<br><br>const PACKAGE_NAME = '@comp/integration-platform';<br><br>/**<br> * Custom Trigger.dev build extension for @comp/integration-platform workspace package.<br> *<br> * Since @comp/integration-platform is a workspace package (not published to npm),<br> * we need to:<br> * 1. Add an esbuild plugin to resolve the import path during build<br> * 2. Copy the built dist files into the trigger.dev deployment<br> */<br>export function integrationPlatformExtension(): IntegrationPlatformExtension {<br>  return new IntegrationPlatformExtension();<br>}<br><br>class IntegrationPlatformExtension implements BuildExtension {<br>  public readonly name = 'IntegrationPlatformExtension';<br>  private _packagePath: string | undefined;<br><br>  async onBuildStart(context: BuildContext) {<br>    if (context.target === 'dev') {<br>      return;<br>    }<br><br>    // Find the package path<br>    this._packagePath = this.findPackageRoot(context.workingDir);<br><br>    if (!this._packagePath) {<br>      throw new Error(<br>        [<br>          `IntegrationPlatformExtension could not find ${PACKAGE_NAME}.`,<br>          'Make sure the package is built (run `bun run build` in packages/integration-platform).',<br>        ].join('\n'),<br>      );<br>    }<br><br>    context.logger.debug(`Found integration-platform at ${this._packagePath}`);<br><br>    // Register esbuild plugin to resolve the workspace package<br>    const packagePath = this._packagePath;<br>    const resolvePlugin: Plugin = {<br>      name: 'resolve-integration-platform',<br>      setup(build) {<br>        // Resolve bare import<br>        build.onResolve({ filter: /^@comp\/integration-platform$/ }, () => {<br>          return {<br>            path: resolve(packagePath, 'dist/index.js'),<br>          };<br>        });<br><br>        // Resolve subpath imports like @comp/integration-platform/types<br>        build.onResolve(<br>          { filter: /^@comp\/integration-platform\// },<br>          (args) => {<br>            const subpath = args.path.replace(`${PACKAGE_NAME}/`, '');<br>            return {<br>              path: resolve(packagePath, 'dist', `${subpath}/index.js`),<br>            };<br>          },<br>        );<br>      },<br>    };<br><br>    context.registerPlugin(resolvePlugin);<br>  }<br><br>  async onBuildComplete(context: BuildContext, manifest: BuildManifest) {<br>    if (context.target === 'dev') {<br>      return;<br>    }<br><br>    const packagePath = this._packagePath;<br>    if (!packagePath) {<br>      return;<br>    }1.  **Start with the `<details>` block** listing all source files.
2.  **No H1 title.**
3.  **Introduction:** Explain what the "Extensions Layer" is, focusing on its role in customizing the build process for specific dependencies or workspace packages. Mention it uses `@trigger.dev/build` extensions.
4.  **Prisma Extension (`PrismaExtension`)**:
    *   **Purpose:** Explain its role in handling Prisma during the build process, especially for the `@trycompai/db` package.
    *   **Key Features:**
        *   Externalizing Prisma-related modules.
        *   Resolving `schema.prisma` path.
        *   Ensuring local Prisma client generation.
        *   Copying schema and generating client in the build output.
        *   Handling environment variables (`DATABASE_URL`, `DIRECT_URL`).
    *   **Methods:** `onBuildStart`, `onBuildComplete`, `ensureLocalPrismaClient`, `runPrismaGenerate`, `resolvePrismaBinary`, `tryResolveSchemaPath`, `buildSchemaCandidates`.
    *   **Diagram:** A flowchart showing the `onBuildStart` and `onBuildComplete` lifecycle, especially schema resolution and client generation.
    *   **Configuration:** `PrismaExtensionOptions`.
5.  **Email Extension (`EmailExtension`)**:
    *   **Purpose:** Explain its role in integrating the `@trycompai/email` workspace package into the build.
    *   **Key Features:**
        *   Finding the package root.
        *   Registering an esbuild plugin for path resolution.
        *   Copying `dist` files and `package.json` to the deployment bundle.
    *   **Methods:** `onBuildStart`, `onBuildComplete`, `findPackageRoot`.
    *   **Diagram:** A sequence diagram showing how `onBuildStart` registers the esbuild plugin and `onBuildComplete` copies files.
6.  **Integration Platform Extension (`IntegrationPlatformExtension`)**:
    *   **Purpose:** Similar to `EmailExtension`, but for `@comp/integration-platform`.
    *   **Key Features:**
        *   Finding the package root.
        *   Registering an esbuild plugin for path resolution.
        *   Copying `dist` files and `package.json` to the deployment bundle.
    *   **Methods:** `onBuildStart`, `onBuildComplete`, `findPackageRoot`.
    *   **Diagram:** A flowchart for the build process, showing the steps of finding the package, registering the plugin, and copying files. This can be similar to the Email Extension but perhaps a high-level flow.
7.  **Overall Architecture/Interaction:** A high-level diagram showing how these extensions fit into the `@trigger.dev/build` lifecycle.

Let's refine the diagrams:
*   **Prisma Extension Flowchart:** Focus on `onBuildStart` and `onBuildComplete` logic, especially schema resolution, `ensureLocalPrismaClient`, and the final `addLayer` call.
*   **Workspace Package Extension (Email/Integration Platform) Sequence Diagram:** Show `BuildContext` interacting with the extension, then the extension interacting with `esbuild` (via `registerPlugin`) and the file system (via `cp`, `mkdir`).

Constraint Checklist & Confidence Score:
1.  <details> block first: Yes
2.  No H1 title: Yes
3.  Based ONLY on source files: Yes
4.  Introduction (1-2 paragraphs): Yes
5.  Detailed Sections (H2, H3): Yes
6.  Explain architecture, components, data flow: Yes
7.  Identify key elements: Yes
8.  Mermaid Diagrams (at least 2): Yes, planning 3.
    *   Flowcharts: Yes
    *   Sequence Diagrams: Yes
    *   Node IDs alphanumeric: Yes
    *   Arrow syntax: Yes
    *   Node labels < 25 chars or <br>: Yes
    *   Wrap labels with special chars in quotes: Yes
    *   No <br> in labels: Yes
    *   Split complex diagrams: Yes
    *   `mermaid` fences: Yes
    *   Valid syntax: Will double check.
9.  Tables: Yes, for options/config.
10. Code Snippets (optional): Yes, for key parts like `prismaExtension` or `emailExtension` function calls.
11. Source Citations: Yes, at the end of each section.
12. Technical Accuracy: Yes
13. Clarity: Yes
14. MDX Components: Yes, will use Callouts, maybe Steps.

Confidence Score: 5/5

Mental Sandbox:
*   For Prisma, the `onBuildStart` is for dev target and `onBuildComplete` is for deployment. I need to make this distinction clear. The `ensureLocalPrismaClient` is called in both, but its purpose differs slightly (local dev vs. preparing for deployment).
*   The `buildSchemaCandidates` logic is important for Prisma, showing how it searches for `schema.prisma`.
*   For Email/Integration, the `findPackageRoot` is crucial. The esbuild `onResolve` setup is also key.
*   I should highlight that these extensions are for workspace packages not published to npm, which is a common use case for custom build logic.

Key information to extract for each extension:
*   **PrismaExtension**:
    *   `PrismaExtensionOptions`: `version`, `migrate`, `directUrlEnvVarName`, `dbPackageVersion`.
    *   `moduleExternals`: `['@prisma/client', '@prisma/engines', '@trycompai/db']`.
    *   `onBuildStart`: Resolves schema, ensures local client (for dev/indexing).
    *   `onBuildComplete`: Resolves schema, ensures local client, copies schema, generates client, adds layer with dependencies and env vars.
    *   `tryResolveSchemaPath` and `buildSchemaCandidates`: How schema is found.
    *   `ensureLocalPrismaClient` and `runPrismaGenerate`: How Prisma client is handled.
*   **EmailExtension**:
    *   `PACKAGE_NAME`: `@trycompai/email`.
    *   `onBuildStart`: Finds package root, registers esbuild plugin to resolve imports to `dist/index.js`.
    *   `onBuildComplete`: Copies `dist` folder and `package.json` to `node_modules/@trycompai/email` in the output.
    *   `findPackageRoot`: Searches relative paths for the package.
*   **IntegrationPlatformExtension**:
    *   `PACKAGE_NAME`: `@comp/integration-platform`.
    *   Similar logic to `EmailExtension` for finding package, registering esbuild plugin, and copying files.

I'll make sure to explicitly mention that these extensions are part of the `@trigger.dev/build` system, which is implied by the imports but good to state directly.The Extensions Layer comprises a set of custom build extensions designed to integrate specific project dependencies and internal workspace packages into the `@trigger.dev/build` process. These extensions customize how certain modules are handled during the build lifecycle, ensuring they are correctly resolved, generated, and bundled for both local development and deployment.

By implementing the `BuildExtension` interface from `@trigger.dev/build`, these extensions hook into critical stages like `onBuildStart` and `onBuildComplete`. This allows them to perform specialized tasks such as managing Prisma client generation, resolving module paths for internal workspace packages not published to npm, and copying necessary build artifacts to the final deployment bundle. This layer is essential for maintaining a consistent and functional application across different environments.

## Prisma Extension

The `PrismaExtension` is a custom build extension specifically designed to manage Prisma integration within the build process, particularly for the `@trycompai/db` package. Its primary function is to ensure that the Prisma schema is correctly located, the Prisma client is generated, and all necessary Prisma-related artifacts are included in the final deployment.

### Purpose and Configuration

This extension handles the complexities of Prisma client generation, which is often required at different stages of the build. It ensures that the `schema.prisma` file is resolved from the `@trycompai/db` package and that the Prisma client is generated locally for development and then again for the deployment bundle.

<Callout title="Important" variant="info">
The `PrismaExtension` is crucial for projects utilizing Prisma, especially when the Prisma schema resides within a shared workspace package. It automates the setup required for Prisma to function correctly in both development and deployed environments.
</Callout>

The behavior of the `PrismaExtension` can be customized using the `PrismaExtensionOptions`.

| Option                 | Type      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <p>The following files were used as context for generating this wiki page:</p>

<ul>
<li>[apps/api/customPrismaExtension.ts](https://github.com/blade47/comp/blob/main/apps/api/customPrismaExtension.ts)</li>
<li>[apps/api/emailExtension.ts](https://github.com/blade47/comp/blob/main/apps/api/emailExtension.ts)</li>
<li>[apps/api/integrationPlatformExtension.ts](https://github.com/blade47/comp/blob/main/apps/api/integrationPlatformExtension.ts)</li>
</ul>
</details>

The Extensions Layer comprises a set of custom build extensions designed to integrate specific project dependencies and internal workspace packages into the `@trigger.dev/build` process. These extensions customize how certain modules are handled during the build lifecycle, ensuring they are correctly resolved, generated, and bundled for both local development and deployment.

By implementing the `BuildExtension` interface from `@trigger.dev/build`, these extensions hook into critical stages like `onBuildStart` and `onBuildComplete`. This allows them to perform specialized tasks such as managing Prisma client generation, resolving module paths for internal workspace packages not published to npm, and copying necessary build artifacts to the final deployment bundle. This layer is essential for maintaining a consistent and functional application across different environments.

## Prisma Extension

The `PrismaExtension` is a custom build extension specifically designed to manage Prisma integration within the build
</details>

## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/49c89830-117b-4def-8edc-b5bcc50766e0/llms.txt) for all pages in this wiki.
