// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.31.1
// source: dashboard.sql

package dbgen

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const listGroups = `-- name: ListGroups :many
SELECT id::text, name, sort_order, collapsed, created_at, updated_at
FROM groups
ORDER BY sort_order ASC, created_at ASC
`

type ListGroupsRow struct {
	ID        string
	Name      string
	SortOrder int32
	Collapsed bool
	CreatedAt pgtype.Timestamptz
	UpdatedAt pgtype.Timestamptz
}

func (q *Queries) ListGroups(ctx context.Context) ([]ListGroupsRow, error) {
	rows, err := q.db.Query(ctx, listGroups)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []ListGroupsRow
	for rows.Next() {
		var i ListGroupsRow
		if err := rows.Scan(
			&i.ID,
			&i.Name,
			&i.SortOrder,
			&i.Collapsed,
			&i.CreatedAt,
			&i.UpdatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listServiceURLs = `-- name: ListServiceURLs :many
SELECT id::text, service_id::text, label, kind, url, sort_order, is_primary, created_at, updated_at
FROM service_urls
ORDER BY service_id, sort_order ASC, created_at ASC
`

type ListServiceURLsRow struct {
	ID        string
	ServiceID string
	Label     string
	Kind      string
	Url       string
	SortOrder int32
	IsPrimary bool
	CreatedAt pgtype.Timestamptz
	UpdatedAt pgtype.Timestamptz
}

func (q *Queries) ListServiceURLs(ctx context.Context) ([]ListServiceURLsRow, error) {
	rows, err := q.db.Query(ctx, listServiceURLs)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []ListServiceURLsRow
	for rows.Next() {
		var i ListServiceURLsRow
		if err := rows.Scan(
			&i.ID,
			&i.ServiceID,
			&i.Label,
			&i.Kind,
			&i.Url,
			&i.SortOrder,
			&i.IsPrimary,
			&i.CreatedAt,
			&i.UpdatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listServices = `-- name: ListServices :many
SELECT id::text, group_id, name, icon_url, icon_asset_id, sort_order, created_at, updated_at
FROM services
ORDER BY group_id NULLS FIRST, sort_order ASC, created_at ASC
`

type ListServicesRow struct {
	ID          string
	GroupID     pgtype.UUID
	Name        string
	IconUrl     pgtype.Text
	IconAssetID pgtype.UUID
	SortOrder   int32
	CreatedAt   pgtype.Timestamptz
	UpdatedAt   pgtype.Timestamptz
}

func (q *Queries) ListServices(ctx context.Context) ([]ListServicesRow, error) {
	rows, err := q.db.Query(ctx, listServices)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []ListServicesRow
	for rows.Next() {
		var i ListServicesRow
		if err := rows.Scan(
			&i.ID,
			&i.GroupID,
			&i.Name,
			&i.IconUrl,
			&i.IconAssetID,
			&i.SortOrder,
			&i.CreatedAt,
			&i.UpdatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const listWidgets = `-- name: ListWidgets :many
SELECT id::text, type, title, enabled, sort_order, config, created_at, updated_at
FROM widget_instances
ORDER BY sort_order ASC, created_at ASC
`

type ListWidgetsRow struct {
	ID        string
	Type      string
	Title     string
	Enabled   bool
	SortOrder int32
	Config    []byte
	CreatedAt pgtype.Timestamptz
	UpdatedAt pgtype.Timestamptz
}

func (q *Queries) ListWidgets(ctx context.Context) ([]ListWidgetsRow, error) {
	rows, err := q.db.Query(ctx, listWidgets)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []ListWidgetsRow
	for rows.Next() {
		var i ListWidgetsRow
		if err := rows.Scan(
			&i.ID,
			&i.Type,
			&i.Title,
			&i.Enabled,
			&i.SortOrder,
			&i.Config,
			&i.CreatedAt,
			&i.UpdatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}
