add item repository

This commit is contained in:
Mads Rasmussen
2023-04-17 16:18:55 +02:00
parent 586a73bfd2
commit 459df80680
3 changed files with 18 additions and 2 deletions

View File

@@ -2,3 +2,4 @@ export * from './data-source';
export * from './detail-repository.interface';
export * from './tree-repository.interface';
export * from './folder-repository.interface';
export * from './item-repository.interface';

View File

@@ -0,0 +1,11 @@
import type { Observable } from 'rxjs';
import { ProblemDetailsModel } from '@umbraco-cms/backoffice/backend-api';
export interface UmbItemRepository<ItemType> {
requestItems: (uniques: string[]) => Promise<{
data: Array<ItemType> | undefined;
error: ProblemDetailsModel | undefined;
asObservable?: () => Observable<Array<ItemType>>;
}>;
items: (uniques: string[]) => Promise<Observable<Array<ItemType>>>;
}

View File

@@ -17,7 +17,9 @@ export interface UmbTreeRepository<ItemType = any, PagedItemType = UmbPagedData<
error: ProblemDetailsModel | undefined;
asObservable?: () => Observable<ItemType[]>;
}>;
requestTreeItems: (uniques: string[]) => Promise<{
// TODO: remove this when all repositories are migrated to the new interface items interface
requestTreeItems?: (uniques: string[]) => Promise<{
data: Array<ItemType> | undefined;
error: ProblemDetailsModel | undefined;
asObservable?: () => Observable<ItemType[]>;
@@ -25,5 +27,7 @@ export interface UmbTreeRepository<ItemType = any, PagedItemType = UmbPagedData<
rootTreeItems: () => Promise<Observable<ItemType[]>>;
treeItemsOf: (parentUnique: string | null) => Promise<Observable<ItemType[]>>;
treeItems: (uniques: string[]) => Promise<Observable<ItemType[]>>;
// TODO: remove this when all repositories are migrated to the new items interface
treeItems?: (uniques: string[]) => Promise<Observable<ItemType[]>>;
}