1import * as Effect from "effect/Effect";
2
3/** Refuse to patch an App observed under a different immutable identity. */
4export const ensureAppImmutableIdentity = (
5 app: {
6 id: string;
7 projectId: string;
8 region: { id: string };
9 },
10 projectId: string,
11 regionId: string,
12) =>
13 app.projectId === projectId && app.region.id === regionId
14 ? Effect.void
15 : Effect.fail(
16 new Error(
17 `Prisma App '${app.id}' has immutable identity project '${app.projectId}' / region '${app.region.id}', but this resource requires project '${projectId}' / region '${regionId}'. Refusing to patch or claim the mismatched App; replace it or import the correct App ID.`,
18 ),
19 );