// Copyright 2025 AGNTCY Contributors (https://github.com/agntcy)
// SPDX-License-Identifier: Apache-2.0

package app

import (
	"context"
	"errors"

	"github.com/agntcy/identity-service/internal/core/app/types"
	"github.com/agntcy/identity-service/internal/pkg/pagination"
	"github.com/agntcy/identity-service/internal/pkg/sorting"
)

type Repository interface {
	CreateApp(
		ctx context.Context,
		app *types.App,
	) (*types.App, error)
	UpdateApp(ctx context.Context, app *types.App) error
	GetApp(
		ctx context.Context,
		id string,
	) (*types.App, error)
	GetAppByResolverMetadataID(
		ctx context.Context,
		resolverMetadataID string,
	) (*types.App, error)
	GetAllApps(
		ctx context.Context,
		paginationFilter pagination.PaginationFilter,
		query *string,
		appTypes []types.AppType,
		sortBy sorting.Sorting,
	) (*pagination.Pageable[types.App], error)
	CountAllApps(ctx context.Context) (int64, error)
	GetAppsByID(ctx context.Context, ids []string) ([]*types.App, error)
	DeleteApp(ctx context.Context, app *types.App) error
	GetAppStatuses(
		ctx context.Context,
		appIDs ...string,
	) (map[string]types.AppStatus, error)
}

var (
	ErrAppNotFound = errors.New("app not found")
)
