Fix AI catalog logic around catalog visibility

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

The following discussion from !199274 (merged) should be addressed:

  • @.luke started a discussion:

    Thought

    It's possible for a flow to be without any released versions, and/or its agents to be without released versions.

    Currently, it could even be public and appear in the catalog. (This is currently the case of all our flow data).

    We'll have to apply some rules around how items canot be used in certain ways until they have released versions, which can use the latest_released_version column #554673 (closed) as a performant way to assess if an item has any released versions:

    1. Only allow flow versions to be released when all of its agents have released versions. (Releasing will set the Item.latest_released_version_id for the item)
    2. Only allow flows and agents to be public if they have released versions (we can check Item.latest_released_version_id as a performant check)
    3. Similar to public check, only allow flows with a Item.latest_released_version_id set be consumed

    We can create a follow-up issue for this.

Edited by 🤖 GitLab Bot 🤖