Provide metadata of main entity in code component utils
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3565754. -->
Reported by: [hooroomoo](https://www.drupal.org/user/3688872)
Related to !446
>>>
<h3 id="overview">Overview</h3>
<p>Introduce a new key `mainEntity` in <code>getPageData</code> function in drupal-utils.ts to also return the current entity's <code>uuid, bundle, and entity type id</code> in Canvas.</p>
<p>Use case for this is let's say we have a code component to show "Related articles" to be used in an article. We do not want to show currently open article in "Related articles" so we want the uuid of the current article to filter it out from the JSON API response.</p>
<h3 id="proposed-resolution">Proposed resolution</h3>
<p>Provide mainEntity metadata (uuid, bundle, and entity type id) of the node being viewed in <code>getPageData</code> from drupal-utils.</p>
<h3 id="alternatives">Alternatives considered</h3>
<blockquote><p>So: not using a type: string, format: uuid prop, which could then receive the host entity's UUID?</p></blockquote>
<p>We decided to not take this approach for now because </p>
<p>1. Can be done without needing to support UUID as a prop which isn’t supported yet.<br>
2. Removes the need for the site builder to manually set the prop to the entity UUID.<br>
3. Follows an existing pattern that is used to get the pageTitle and breadcrumb accessible through drupalSettings.</p>
<p>But if we find that this approach has limitations down the line, we will revisit the UUID as prop approach as a long term solution.</p>
> Related issue: [Issue #3566541](https://www.drupal.org/node/3566541)
> Related issue: [Issue #3551787](https://www.drupal.org/node/3551787)
> Related issue: [Issue #3566934](https://www.drupal.org/node/3566934)
issue