import * as Data from "effect/Data";
import * as Effect from "effect/Effect";
export class AppIdentityConflict extends Data.TaggedError("AppIdentityConflict")<{
readonly message: string;
readonly cause?: unknown;
}> {}
/** Refuse to patch an App observed under a different immutable identity. */
export const ensureAppImmutableIdentity = (
app: {
id: string;
projectId: string;
region: { id: string };
},
projectId: string,
regionId: string,
) =>
app.projectId === projectId && app.region.id === regionId
? Effect.void
: Effect.fail(
new AppIdentityConflict({
message: `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.`,
}),
);