Skip to content

Commit bfba94c

Browse files
d-csclaude
andcommitted
style(run-ops): apply oxfmt
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8b79e94 commit bfba94c

7 files changed

Lines changed: 81 additions & 62 deletions

apps/webapp/app/db.server.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ function tagDatasourceRunOps(
155155
// Same wrapper as captureInfrastructureErrors, bridged via double cast because
156156
// that helper is constrained to T extends @trigger.dev/database.PrismaClient.
157157
function captureInfraErrorsRunOps(client: RunOpsPrismaClient): RunOpsPrismaClient {
158-
return captureInfrastructureErrors(client as unknown as PrismaClient) as unknown as RunOpsPrismaClient;
158+
return captureInfrastructureErrors(
159+
client as unknown as PrismaClient
160+
) as unknown as RunOpsPrismaClient;
159161
}
160162

161163
export const prisma = singleton("prisma", () =>
@@ -260,8 +262,10 @@ export const runOpsNewPrismaClient: RunOpsPrismaClient = runOpsTopology.newRunOp
260262
export const runOpsNewReplicaClient: RunOpsPrismaClient = runOpsTopology.newRunOps.replica;
261263
// Legacy-typed aliases kept for the remaining consumers that still expect PrismaClient /
262264
// PrismaReplicaClient (idempotency residency, read-through, handlers, cascade cleanup).
263-
export const runOpsNewPrisma: PrismaClient = runOpsTopology.newRunOps.writer as unknown as PrismaClient;
264-
export const runOpsNewReplica: PrismaReplicaClient = runOpsTopology.newRunOps.replica as unknown as PrismaReplicaClient;
265+
export const runOpsNewPrisma: PrismaClient = runOpsTopology.newRunOps
266+
.writer as unknown as PrismaClient;
267+
export const runOpsNewReplica: PrismaReplicaClient = runOpsTopology.newRunOps
268+
.replica as unknown as PrismaReplicaClient;
265269
export const runOpsLegacyPrisma: PrismaClient = runOpsTopology.legacyRunOps.writer;
266270
export const runOpsLegacyReplica: PrismaReplicaClient = runOpsTopology.legacyRunOps.replica;
267271

apps/webapp/app/v3/runOpsMigration/runEngineControlPlaneResolver.server.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import type {
66
} from "@internal/run-engine";
77
import type { RuntimeEnvironmentType } from "@trigger.dev/database";
88
import { $replica } from "~/db.server";
9-
import {
10-
authIncludeWithParent,
11-
toAuthenticated,
12-
} from "~/models/runtimeEnvironment.server";
9+
import { authIncludeWithParent, toAuthenticated } from "~/models/runtimeEnvironment.server";
1310
import {
1411
ControlPlaneResolver as AppControlPlaneResolver,
1512
controlPlaneResolver,
@@ -64,9 +61,7 @@ export class RunEngineControlPlaneResolver implements EngineControlPlaneResolver
6461
});
6562
}
6663

67-
async resolveAuthenticatedEnv(
68-
environmentId: string
69-
): Promise<ResolvedAuthenticatedEnv | null> {
64+
async resolveAuthenticatedEnv(environmentId: string): Promise<ResolvedAuthenticatedEnv | null> {
7065
// Mirror findEnvironmentById's data source ($replica) and auth shape, but the
7166
// engine needs `git` too. A single findFirst with `include: authIncludeWithParent`
7267
// returns all RuntimeEnvironment scalars (including `git`) on the row, so we map
@@ -94,4 +89,6 @@ export class RunEngineControlPlaneResolver implements EngineControlPlaneResolver
9489
}
9590

9691
// Module-level singleton over the app resolver singleton.
97-
export const runEngineControlPlaneResolver = new RunEngineControlPlaneResolver(controlPlaneResolver);
92+
export const runEngineControlPlaneResolver = new RunEngineControlPlaneResolver(
93+
controlPlaneResolver
94+
);

apps/webapp/app/v3/runStore.server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ export function buildRunStore(deps: BuildRunStoreDeps): RunStore {
7676
// RUN_OPS_SPLIT_ENABLED. Reads must fan out across both DBs so a run that lives on the new
7777
// DB stays visible even with the flag off (matches the db.server topology factory). The flag
7878
// governs write/mint residency + migration via isSplitEnabled(), not read visibility.
79-
const ROUTING_ENABLED =
80-
!!env.TASK_RUN_DATABASE_URL && !!env.TASK_RUN_LEGACY_DATABASE_URL;
79+
const ROUTING_ENABLED = !!env.TASK_RUN_DATABASE_URL && !!env.TASK_RUN_LEGACY_DATABASE_URL;
8180

8281
// Resolve the run-ops handles, tolerating contexts where they are absent — tests that mock
8382
// ~/db.server minimally omit them, and accessing a missing export under vi.mock throws. A

apps/webapp/test/runDetailLoaders.controlPlane.readthrough.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ describe("run-detail loaders cross-DB read-through (dedicated run-ops client)",
118118
expect(found!.id).toBe(run.id);
119119

120120
const authorized = await cp14.project.findFirst({
121-
where: { id: found!.projectId, organization: { members: { some: { userId: cp.member.id } } } },
121+
where: {
122+
id: found!.projectId,
123+
organization: { members: { some: { userId: cp.member.id } } },
124+
},
122125
select: { id: true },
123126
});
124127
expect(authorized).not.toBeNull();
@@ -148,7 +151,10 @@ describe("run-detail loaders cross-DB read-through (dedicated run-ops client)",
148151
expect(found).not.toBeNull();
149152

150153
const authorized = await cp14.project.findFirst({
151-
where: { id: found!.projectId, organization: { members: { some: { userId: cp.stranger.id } } } },
154+
where: {
155+
id: found!.projectId,
156+
organization: { members: { some: { userId: cp.stranger.id } } },
157+
},
152158
select: { id: true },
153159
});
154160
expect(authorized).toBeNull();
@@ -165,7 +171,15 @@ describe("run-detail loaders cross-DB read-through (dedicated run-ops client)",
165171

166172
const found = await runStore.findRun(
167173
{ friendlyId: run.friendlyId },
168-
{ select: { id: true, idempotencyKey: true, taskIdentifier: true, projectId: true, runtimeEnvironmentId: true } }
174+
{
175+
select: {
176+
id: true,
177+
idempotencyKey: true,
178+
taskIdentifier: true,
179+
projectId: true,
180+
runtimeEnvironmentId: true,
181+
},
182+
}
169183
);
170184
const env = await resolver.resolveAuthenticatedEnv(found!.runtimeEnvironmentId);
171185
expect(env!.slug).toBe(cp.environment.slug);

apps/webapp/test/v3/runOpsMigration/controlPlaneRepoint.server.test.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,23 @@ heteroPostgresTest(
127127

128128
// --- Relaxed-cache (no latency regression) -------------------------
129129

130-
heteroPostgresTest(
131-
"relaxed (longer TTL) cache still hits on the new DB",
132-
async ({ prisma17 }) => {
133-
const { environment } = await seedControlPlane(prisma17);
134-
const { client: counting, reads } = countQueries(prisma17);
135-
const resolver = new ControlPlaneResolver({
136-
controlPlanePrimary: counting,
137-
controlPlaneReplica: counting,
138-
// Relaxed: a much longer TTL than the default — same-provider resolution is cheap.
139-
cache: new ControlPlaneCache({ ttlMs: 300_000, maxEntries: 10_000 }),
140-
splitEnabled: () => true,
141-
});
130+
heteroPostgresTest("relaxed (longer TTL) cache still hits on the new DB", async ({ prisma17 }) => {
131+
const { environment } = await seedControlPlane(prisma17);
132+
const { client: counting, reads } = countQueries(prisma17);
133+
const resolver = new ControlPlaneResolver({
134+
controlPlanePrimary: counting,
135+
controlPlaneReplica: counting,
136+
// Relaxed: a much longer TTL than the default — same-provider resolution is cheap.
137+
cache: new ControlPlaneCache({ ttlMs: 300_000, maxEntries: 10_000 }),
138+
splitEnabled: () => true,
139+
});
142140

143-
expect(await resolver.resolveEnv(environment.id)).toMatchObject({ id: environment.id });
144-
expect(reads()).toBe(1);
145-
// Second read served from the relaxed cache — no extra DB round-trip.
146-
await resolver.resolveEnv(environment.id);
147-
expect(reads()).toBe(1);
148-
}
149-
);
141+
expect(await resolver.resolveEnv(environment.id)).toMatchObject({ id: environment.id });
142+
expect(reads()).toBe(1);
143+
// Second read served from the relaxed cache — no extra DB round-trip.
144+
await resolver.resolveEnv(environment.id);
145+
expect(reads()).toBe(1);
146+
});
150147

151148
// --- Cross-version transition (legacy DB -> new DB) -----------------------
152149

apps/webapp/test/v3/runOpsMigration/distinctDbSentinel.server.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ describe("probeDistinctDatabases", () => {
3737
async ({ postgresContainer14, uri14 }) => {
3838
const otherDb = `sentinel_other_${Date.now()}`;
3939
const admin = new PrismaClient({
40-
datasources: { db: { url: urlWithDatabase(postgresContainer14.getConnectionUri(), "postgres") } },
40+
datasources: {
41+
db: { url: urlWithDatabase(postgresContainer14.getConnectionUri(), "postgres") },
42+
},
4143
});
4244
try {
4345
await admin.$executeRawUnsafe(`CREATE DATABASE "${otherDb}"`);

apps/webapp/test/v3/runOpsMigration/runEngineControlPlaneResolver.server.test.ts

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,28 @@ async function seedWorker(
119119
}
120120

121121
describe("RunEngineControlPlaneResolver adapter", () => {
122-
heteroPostgresTest("resolveEnv maps app ResolvedEnv onto ResolvedEngineEnv", async ({ prisma14 }) => {
123-
const { organization, project, environment } = await seedEnv(prisma14, "PRODUCTION");
124-
const adapter = new RunEngineControlPlaneResolver(buildAppResolver(prisma14));
122+
heteroPostgresTest(
123+
"resolveEnv maps app ResolvedEnv onto ResolvedEngineEnv",
124+
async ({ prisma14 }) => {
125+
const { organization, project, environment } = await seedEnv(prisma14, "PRODUCTION");
126+
const adapter = new RunEngineControlPlaneResolver(buildAppResolver(prisma14));
125127

126-
const env = await adapter.resolveEnv(environment.id);
127-
expect(env).not.toBeNull();
128-
expect(env!.id).toBe(environment.id);
129-
expect(env!.type).toBe("PRODUCTION");
130-
expect(env!.projectId).toBe(project.id);
131-
expect(env!.organizationId).toBe(organization.id);
132-
// Nested + concurrency fields the run-engine MinimalAuthenticatedEnvironment requires.
133-
expect(env!.project.id).toBe(project.id);
134-
expect(env!.organization.id).toBe(organization.id);
135-
expect(env!.maximumConcurrencyLimit).toBe(9);
136-
expect(env!.concurrencyLimitBurstFactor.toNumber()).toBe(2);
137-
expect(env!.archivedAt).toBeNull();
128+
const env = await adapter.resolveEnv(environment.id);
129+
expect(env).not.toBeNull();
130+
expect(env!.id).toBe(environment.id);
131+
expect(env!.type).toBe("PRODUCTION");
132+
expect(env!.projectId).toBe(project.id);
133+
expect(env!.organizationId).toBe(organization.id);
134+
// Nested + concurrency fields the run-engine MinimalAuthenticatedEnvironment requires.
135+
expect(env!.project.id).toBe(project.id);
136+
expect(env!.organization.id).toBe(organization.id);
137+
expect(env!.maximumConcurrencyLimit).toBe(9);
138+
expect(env!.concurrencyLimitBurstFactor.toNumber()).toBe(2);
139+
expect(env!.archivedAt).toBeNull();
138140

139-
expect(await adapter.resolveEnv("env_missing")).toBeNull();
140-
});
141+
expect(await adapter.resolveEnv("env_missing")).toBeNull();
142+
}
143+
);
141144

142145
heteroPostgresTest(
143146
"resolveWorkerVersion (deployed, no workerId) resolves the promoted MANAGED deployment",
@@ -156,7 +159,9 @@ describe("RunEngineControlPlaneResolver adapter", () => {
156159
});
157160
expect(version).not.toBeNull();
158161
expect(version!.worker.id).toBe(seeded.worker.id);
159-
expect(version!.deployment?.id).toBe("deployment" in seeded ? seeded.deployment.id : undefined);
162+
expect(version!.deployment?.id).toBe(
163+
"deployment" in seeded ? seeded.deployment.id : undefined
164+
);
160165
expect(version!.tasks.map((t) => t.slug)).toContain("my-task");
161166
}
162167
);
@@ -182,13 +187,14 @@ describe("RunEngineControlPlaneResolver adapter", () => {
182187
}
183188
);
184189

185-
heteroPostgresTest("assertEnvExists resolves for a present env, rejects for a missing one", async ({
186-
prisma14,
187-
}) => {
188-
const { environment } = await seedEnv(prisma14, "PRODUCTION");
189-
const adapter = new RunEngineControlPlaneResolver(buildAppResolver(prisma14));
190+
heteroPostgresTest(
191+
"assertEnvExists resolves for a present env, rejects for a missing one",
192+
async ({ prisma14 }) => {
193+
const { environment } = await seedEnv(prisma14, "PRODUCTION");
194+
const adapter = new RunEngineControlPlaneResolver(buildAppResolver(prisma14));
190195

191-
await expect(adapter.assertEnvExists(environment.id)).resolves.toBeUndefined();
192-
await expect(adapter.assertEnvExists("env_missing")).rejects.toThrow();
193-
});
196+
await expect(adapter.assertEnvExists(environment.id)).resolves.toBeUndefined();
197+
await expect(adapter.assertEnvExists("env_missing")).rejects.toThrow();
198+
}
199+
);
194200
});

0 commit comments

Comments
 (0)