36 lines
948 B
TypeScript
36 lines
948 B
TypeScript
import "server-only";
|
|
|
|
import { executeContentDatabaseMutation } from "./mutation-runtime-database";
|
|
import { executeContentExternalMutation } from "./mutation-runtime-external";
|
|
import type {
|
|
ContentMutationContext,
|
|
ContentMutationOperation,
|
|
ContentMutationSnapshot,
|
|
} from "./mutations";
|
|
import { ContentMutationFailure } from "./mutations";
|
|
|
|
export async function executeContentMutationOperation(
|
|
operation: ContentMutationOperation,
|
|
input: unknown,
|
|
context: ContentMutationContext,
|
|
transaction?: unknown,
|
|
): Promise<ContentMutationSnapshot> {
|
|
const databaseResult = await executeContentDatabaseMutation(
|
|
operation,
|
|
input,
|
|
context,
|
|
transaction,
|
|
);
|
|
if (databaseResult) return databaseResult;
|
|
const externalResult = await executeContentExternalMutation(
|
|
operation,
|
|
input,
|
|
context,
|
|
);
|
|
if (externalResult) return externalResult;
|
|
throw new ContentMutationFailure(
|
|
"VALIDATION",
|
|
"errors.housekeeping.validation",
|
|
);
|
|
}
|