-- NOTE: This file is auto generated by ./sql-generator

-- PluginRepository.getPlugin
select
  "plugin"."id" as "id",
  "plugin"."name" as "name",
  "plugin"."title" as "title",
  "plugin"."description" as "description",
  "plugin"."author" as "author",
  "plugin"."version" as "version",
  "plugin"."wasmPath" as "wasmPath",
  "plugin"."createdAt" as "createdAt",
  "plugin"."updatedAt" as "updatedAt",
  (
    select
      coalesce(json_agg(agg), '[]')
    from
      (
        select
          *
        from
          "plugin_filter"
        where
          "plugin_filter"."pluginId" = "plugin"."id"
      ) as agg
  ) as "filters",
  (
    select
      coalesce(json_agg(agg), '[]')
    from
      (
        select
          *
        from
          "plugin_action"
        where
          "plugin_action"."pluginId" = "plugin"."id"
      ) as agg
  ) as "actions"
from
  "plugin"
where
  "plugin"."id" = $1

-- PluginRepository.getPluginByName
select
  "plugin"."id" as "id",
  "plugin"."name" as "name",
  "plugin"."title" as "title",
  "plugin"."description" as "description",
  "plugin"."author" as "author",
  "plugin"."version" as "version",
  "plugin"."wasmPath" as "wasmPath",
  "plugin"."createdAt" as "createdAt",
  "plugin"."updatedAt" as "updatedAt",
  (
    select
      coalesce(json_agg(agg), '[]')
    from
      (
        select
          *
        from
          "plugin_filter"
        where
          "plugin_filter"."pluginId" = "plugin"."id"
      ) as agg
  ) as "filters",
  (
    select
      coalesce(json_agg(agg), '[]')
    from
      (
        select
          *
        from
          "plugin_action"
        where
          "plugin_action"."pluginId" = "plugin"."id"
      ) as agg
  ) as "actions"
from
  "plugin"
where
  "plugin"."name" = $1

-- PluginRepository.getAllPlugins
select
  "plugin"."id" as "id",
  "plugin"."name" as "name",
  "plugin"."title" as "title",
  "plugin"."description" as "description",
  "plugin"."author" as "author",
  "plugin"."version" as "version",
  "plugin"."wasmPath" as "wasmPath",
  "plugin"."createdAt" as "createdAt",
  "plugin"."updatedAt" as "updatedAt",
  (
    select
      coalesce(json_agg(agg), '[]')
    from
      (
        select
          *
        from
          "plugin_filter"
        where
          "plugin_filter"."pluginId" = "plugin"."id"
      ) as agg
  ) as "filters",
  (
    select
      coalesce(json_agg(agg), '[]')
    from
      (
        select
          *
        from
          "plugin_action"
        where
          "plugin_action"."pluginId" = "plugin"."id"
      ) as agg
  ) as "actions"
from
  "plugin"
order by
  "plugin"."name"

-- PluginRepository.getFilter
select
  *
from
  "plugin_filter"
where
  "id" = $1

-- PluginRepository.getFiltersByPlugin
select
  *
from
  "plugin_filter"
where
  "pluginId" = $1

-- PluginRepository.getAction
select
  *
from
  "plugin_action"
where
  "id" = $1

-- PluginRepository.getActionsByPlugin
select
  *
from
  "plugin_action"
where
  "pluginId" = $1
