Files
James Ritchie 65fa8300ad Support for more frameworks (#446)
* Removed next references in the ReadMe

* FAQ improvements to update Next.js references

* Added a new Frameworks page with logos to link to the quick start guides

* Renamed the mdx file so the link works

* Added basic platform guides

* Introduction doesn’t reference next.js only

* Added a note about serverless and restructured the side menu

* Added more frameworks pages to the manual install section

* Fixed SVG error

* Coming soon guides now using snippets so they can be in 2 places while we work on them

* Removed redirects

* Added a new named icon

* increased fireworks particle count slightly

* Creating a route for the onboarding and link to access it anytime from the side menu

* Moved the onboarding into new components

* Updated the routes for the onboarding page

* Onboarding is now Setup and the frameworks overview page now links to different framework page in the onboarding side nav

* URLs and pages renamed to ‘setup’

* URLs and pages renamed to ‘setup’

* Fixed some old named component imports

* WIP on a new less hacked-in background image

* Added svg logos for all the frameworks

* New paths for the new framework pages

* Side menu collapses once you selected a framework

* Temporary Nuxt page

* New routes for the new frameworks

* New ‘framework coming soon’ component - now used in the coming soon framework pages

* Moved/removed files

* Moved all svg framework logos into a new folder and file

* balanced the logo sizes

* Framework coming soon pages take a name and url

* New express svg logo

* New component for a Framework item in the grid

* Added information and design for the coming soon frameworks

* Change the grid to 1 row if jobs === 0

* Updated the framework coming soon snippet and added it to the relevant pages

* Express now 2nd in all lists

* Added link to long running server support discussion

* New logo to include next.js + supabase quick start

* roadmap now links to homepage with page anchor to roadmap section

* changelog now links to Github releases page

* Removed reference to Next.js

* Docs pages with coming soon info all share the same framework snippets

* Fixed issue of missing props

* Moved the fireworks effect into a separate file to make it easier for adding more framework onboarding pages

* Info callouts have a more muted style

* Added a callout to the top of the next onboarding to reference Serverless-only support

* Moved the callout explaining scheduled triggers not working in dev to the bottom of the test panel

This is to resolve eric’s UX ticket: https://github.com/triggerdotdev/trigger.dev/issues/416

* Added groundwork for Nest.js framework

* Using framer motion for the menu transition instead of css - now has a slight spring and is snappier

* redirect the manual setup page to the new nextjs setup page

* Fixed broken docs link

* Added a readme.md to next.js package

* Capital I for integration

* Renamed component: NextDevCommand to RunDevCommand

* Made required props non-optional

* CLI now points at manual install guides if no Next project detected

* Explicitly made supported default to false (it was working but a bit hard to read)

* Added links to all github issues for the frameworks coming soon component

---------

Co-authored-by: Matt Aitken <matt@mattaitken.com>
2023-09-08 17:26:08 +01:00

365 lines
9.8 KiB
TypeScript

import type { Integration, TriggerSource } from "@trigger.dev/database";
import { z } from "zod";
import { Job } from "~/models/job.server";
import type { Organization } from "~/models/organization.server";
import type { Project } from "~/models/project.server";
export type OrgForPath = Pick<Organization, "slug">;
export type ProjectForPath = Pick<Project, "slug">;
export type JobForPath = Pick<Job, "slug">;
export type RunForPath = Pick<Job, "id">;
export type IntegrationForPath = Pick<Integration, "slug">;
export type TriggerForPath = Pick<TriggerSource, "id">;
export const OrganizationParamsSchema = z.object({
organizationSlug: z.string(),
});
export const ProjectParamSchema = OrganizationParamsSchema.extend({
projectParam: z.string(),
});
export const JobParamsSchema = ProjectParamSchema.extend({
jobParam: z.string(),
});
export const RunParamsSchema = JobParamsSchema.extend({
runParam: z.string(),
});
export const TaskParamsSchema = RunParamsSchema.extend({
taskParam: z.string(),
});
export const IntegrationClientParamSchema = ProjectParamSchema.extend({
clientParam: z.string(),
});
export const TriggerSourceParamSchema = ProjectParamSchema.extend({
triggerParam: z.string(),
});
export const TriggerSourceRunParamsSchema = TriggerSourceParamSchema.extend({
runParam: z.string(),
});
export const TriggerSourceRunTaskParamsSchema = TriggerSourceRunParamsSchema.extend({
taskParam: z.string(),
});
export function trimTrailingSlash(path: string) {
return path.replace(/\/$/, "");
}
export function parentPath(path: string) {
const trimmedTrailingSlash = trimTrailingSlash(path);
const lastSlashIndex = trimmedTrailingSlash.lastIndexOf("/");
return trimmedTrailingSlash.substring(0, lastSlashIndex);
}
export function organizationsPath() {
return `/`;
}
export function accountPath() {
return `/account`;
}
export function invitesPath() {
return `/invites`;
}
export function confirmBasicDetailsPath() {
return `/confirm-basic-details`;
}
export function acceptInvitePath(token: string) {
return `/invite-accept?token=${token}`;
}
export function resendInvitePath() {
return `/invite-resend`;
}
export function logoutPath() {
return `/logout`;
}
// Org
export function organizationPath(organization: OrgForPath) {
return `/orgs/${organizationParam(organization)}`;
}
export function newOrganizationPath() {
return `/orgs/new`;
}
export function organizationTeamPath(organization: OrgForPath) {
return `${organizationPath(organization)}/team`;
}
export function inviteTeamMemberPath(organization: OrgForPath) {
return `${organizationPath(organization)}/invite`;
}
export function organizationBillingPath(organization: OrgForPath) {
return `${organizationPath(organization)}/billing`;
}
function organizationParam(organization: OrgForPath) {
return organization.slug;
}
// Project
export function projectPath(organization: OrgForPath, project: ProjectForPath) {
return `/orgs/${organizationParam(organization)}/projects/${projectParam(project)}`;
}
export function projectSetupPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup`;
}
export function projectSetupNextjsPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup/nextjs`;
}
export function projectSetupRemixPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup/remix`;
}
export function projectSetupExpressPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup/express`;
}
export function projectSetupRedwoodPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup/redwood`;
}
export function projectSetupNuxtPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup/nuxt`;
}
export function projectSetupSvelteKitPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup/sveltekit`;
}
export function projectSetupFastifyPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup/fastify`;
}
export function projectSetupAstroPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup/astro`;
}
export function projectSetupNestjsPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/setup/nestjs`;
}
export function projectJobsPath(organization: OrgForPath, project: ProjectForPath) {
return projectPath(organization, project);
}
export function projectIntegrationsPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/integrations`;
}
export function projectTriggersPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/triggers`;
}
export function projectEnvironmentsPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectPath(organization, project)}/environments`;
}
export function projectStreamingPath(id: string) {
return `/resources/projects/${id}/jobs/stream`;
}
export function projectEnvironmentsStreamingPath(
organization: OrgForPath,
project: ProjectForPath
) {
return `${projectEnvironmentsPath(organization, project)}/stream`;
}
export function endpointStreamingPath(environment: { id: string }) {
return `/resources/environments/${environment.id}/endpoint/stream`;
}
export function newProjectPath(organization: OrgForPath) {
return `${organizationPath(organization)}/projects/new`;
}
function projectParam(project: ProjectForPath) {
return project.slug;
}
// Integration
export function integrationClientPath(
organization: OrgForPath,
project: ProjectForPath,
client: IntegrationForPath
) {
return `${projectIntegrationsPath(organization, project)}/${clientParam(client)}`;
}
export function integrationClientConnectionsPath(
organization: OrgForPath,
project: ProjectForPath,
client: IntegrationForPath
) {
return `${integrationClientPath(organization, project, client)}/connections`;
}
export function integrationClientScopesPath(
organization: OrgForPath,
project: ProjectForPath,
client: IntegrationForPath
) {
return `${integrationClientPath(organization, project, client)}/scopes`;
}
function clientParam(integration: IntegrationForPath) {
return integration.slug;
}
// Triggers
export function projectScheduledTriggersPath(organization: OrgForPath, project: ProjectForPath) {
return `${projectTriggersPath(organization, project)}/scheduled`;
}
export function externalTriggerPath(
organization: OrgForPath,
project: ProjectForPath,
trigger: TriggerForPath
) {
return `${projectTriggersPath(organization, project)}/external/${triggerSourceParam(trigger)}`;
}
export function externalTriggerRunsParentPath(
organization: OrgForPath,
project: ProjectForPath,
trigger: TriggerForPath
) {
return `${externalTriggerPath(organization, project, trigger)}/runs`;
}
export function externalTriggerRunPath(
organization: OrgForPath,
project: ProjectForPath,
trigger: TriggerForPath,
run: RunForPath
) {
return `${externalTriggerRunsParentPath(organization, project, trigger)}/${run.id}`;
}
export function externalTriggerRunStreamingPath(
organization: OrgForPath,
project: ProjectForPath,
trigger: TriggerForPath,
run: RunForPath
) {
return `${externalTriggerRunPath(organization, project, trigger, run)}/stream`;
}
function triggerSourceParam(trigger: TriggerForPath) {
return trigger.id;
}
// Job
export function jobPath(organization: OrgForPath, project: ProjectForPath, job: JobForPath) {
return `${projectPath(organization, project)}/jobs/${jobParam(job)}`;
}
export function jobTestPath(organization: OrgForPath, project: ProjectForPath, job: JobForPath) {
return `${jobPath(organization, project, job)}/test`;
}
export function jobTriggerPath(organization: OrgForPath, project: ProjectForPath, job: JobForPath) {
return `${jobPath(organization, project, job)}/trigger`;
}
export function jobSettingsPath(
organization: OrgForPath,
project: ProjectForPath,
job: JobForPath
) {
return `${jobPath(organization, project, job)}/settings`;
}
export function jobParam(job: JobForPath) {
return job.slug;
}
// Run
export function jobRunsParentPath(
organization: OrgForPath,
project: ProjectForPath,
job: JobForPath
) {
return `${jobPath(organization, project, job)}/runs`;
}
export function runPath(
organization: OrgForPath,
project: ProjectForPath,
job: JobForPath,
run: RunForPath
) {
return `${jobRunsParentPath(organization, project, job)}/${runParam(run)}`;
}
export function jobRunDashboardPath(
organization: OrgForPath,
project: ProjectForPath,
job: JobForPath,
run: RunForPath
) {
return runTriggerPath(runPath(organization, project, job, run));
}
export function runStreamingPath(
organization: OrgForPath,
project: ProjectForPath,
job: JobForPath,
run: RunForPath
) {
return `${runPath(organization, project, job, run)}/stream`;
}
export function runParam(run: RunForPath) {
return run.id;
}
// Task
export function runTaskPath(runPath: string, taskId: string) {
return `${runPath}/tasks/${taskId}`;
}
// Event
export function runTriggerPath(runPath: string) {
return `${runPath}/trigger`;
}
// Event
export function runCompletedPath(runPath: string) {
return `${runPath}/completed`;
}
// Docs
export function docsRoot() {
return "https://trigger.dev/docs";
}
export function docsPath(path: string) {
return `${docsRoot()}/${path}`;
}
export function docsIntegrationPath(api: string) {
return `${docsRoot()}/integrations/apis/${api}`;
}
export function docsCreateIntegration() {
return `${docsRoot()}/integrations/create`;
}