import { runRouteMutationGuards } from "@open-mercato/shared/lib/crud/route-mutation-guard";
async function validateRouteMutationGuard(params) {
  const { auth, container, input, req } = params;
  if (!auth.sub || !auth.tenantId) {
    return { result: null, afterSuccess: async () => void 0 };
  }
  const guarded = await runRouteMutationGuards({
    container,
    req,
    auth: {
      userId: auth.sub,
      tenantId: auth.tenantId,
      organizationId: auth.orgId ?? null
    },
    input: {
      resourceKind: input.resourceKind,
      resourceId: input.resourceId,
      operation: input.operation ?? "custom",
      mutationPayload: input.mutationPayload ?? null
    }
  });
  if (!guarded.ok) {
    return { response: guarded.response };
  }
  return {
    result: { ok: true },
    afterSuccess: guarded.runAfterSuccess
  };
}
export {
  validateRouteMutationGuard
};
//# sourceMappingURL=route-mutation-guard.js.map
