use types
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { UmbRepositoryBase } from '../repository-base.js';
|
||||
import type { UmbRepositoryResponse, UmbRepositoryResponseWithAsObservable } from '../types.js';
|
||||
import type { UmbDetailDataSource, UmbDetailDataSourceConstructor } from './detail-data-source.interface.js';
|
||||
import type { UmbDetailRepository } from './detail-repository.interface.js';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
@@ -51,7 +52,7 @@ export abstract class UmbDetailRepositoryBase<
|
||||
* @returns {*}
|
||||
* @memberof UmbDetailRepositoryBase
|
||||
*/
|
||||
async createScaffold(preset?: Partial<DetailModelType>) {
|
||||
async createScaffold(preset?: Partial<DetailModelType>): Promise<UmbRepositoryResponse<DetailModelType>> {
|
||||
return this.detailDataSource.createScaffold(preset);
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ export abstract class UmbDetailRepositoryBase<
|
||||
* @returns {*}
|
||||
* @memberof UmbDetailRepositoryBase
|
||||
*/
|
||||
async requestByUnique(unique: string) {
|
||||
async requestByUnique(unique: string): Promise<UmbRepositoryResponseWithAsObservable<DetailModelType>> {
|
||||
if (!unique) throw new Error('Unique is missing');
|
||||
await this.#init;
|
||||
|
||||
@@ -71,7 +72,11 @@ export abstract class UmbDetailRepositoryBase<
|
||||
this.#detailStore!.append(data);
|
||||
}
|
||||
|
||||
return { data, error, asObservable: () => this.#detailStore!.byUnique(unique) };
|
||||
return {
|
||||
data,
|
||||
error,
|
||||
asObservable: () => this.#detailStore!.byUnique(unique),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +86,7 @@ export abstract class UmbDetailRepositoryBase<
|
||||
* @returns {*}
|
||||
* @memberof UmbDetailRepositoryBase
|
||||
*/
|
||||
async create(model: DetailModelType, parentUnique: string | null) {
|
||||
async create(model: DetailModelType, parentUnique: string | null): Promise<UmbRepositoryResponse<DetailModelType>> {
|
||||
if (!model) throw new Error('Data is missing');
|
||||
await this.#init;
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@ export * from './item/index.js';
|
||||
export * from './detail/index.js';
|
||||
|
||||
export type { UmbDataSourceResponse, UmbDataSourceErrorResponse } from './data-source-response.interface.js';
|
||||
export type { UmbPagedModel, UmbRepositoryResponse, UmbRepositoryErrorResponse } from './types.js';
|
||||
export type * from './types.js';
|
||||
|
||||
@@ -12,5 +12,5 @@ export interface UmbRepositoryResponse<T> extends UmbDataSourceResponse<T> {}
|
||||
export interface UmbRepositoryErrorResponse extends UmbDataSourceErrorResponse {}
|
||||
|
||||
export interface UmbRepositoryResponseWithAsObservable<T> extends UmbRepositoryResponse<T> {
|
||||
asObservable?: () => Observable<T | undefined>;
|
||||
asObservable: () => Observable<T | undefined>;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
import { UMB_DOCUMENTS_SECTION_PATH } from '../../section/paths.js';
|
||||
import { UmbDocumentPreviewRepository } from '../repository/preview/index.js';
|
||||
import { sortVariants } from '../utils.js';
|
||||
import { UMB_DOCUMENT_COLLECTION_ALIAS } from '../collection/index.js';
|
||||
import { UMB_DOCUMENT_DETAIL_MODEL_VARIANT_SCAFFOLD, UMB_DOCUMENT_WORKSPACE_ALIAS } from './constants.js';
|
||||
import { UmbEntityContext, type UmbEntityModel } from '@umbraco-cms/backoffice/entity';
|
||||
import { UMB_INVARIANT_CULTURE, UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
@@ -73,7 +74,7 @@ import type { UmbDocumentTypeDetailModel } from '@umbraco-cms/backoffice/documen
|
||||
import { UmbIsTrashedEntityContext } from '@umbraco-cms/backoffice/recycle-bin';
|
||||
import { UmbReadOnlyVariantStateManager } from '@umbraco-cms/backoffice/utils';
|
||||
import { UmbDataTypeItemRepositoryManager } from '@umbraco-cms/backoffice/data-type';
|
||||
import { UMB_DOCUMENT_COLLECTION_ALIAS } from '../collection/index.js';
|
||||
import type { UmbRepositoryResponse } from '@umbraco-cms/backoffice/repository';
|
||||
|
||||
type EntityModel = UmbDocumentDetailModel;
|
||||
type EntityTypeModel = UmbDocumentTypeDetailModel;
|
||||
@@ -95,8 +96,8 @@ export class UmbDocumentWorkspaceContext
|
||||
readonly parentEntityType = this.#parent.asObservablePart((parent) => (parent ? parent.entityType : undefined));
|
||||
|
||||
readonly #data = new UmbContentWorkspaceDataManager<EntityModel>(this, UMB_DOCUMENT_DETAIL_MODEL_VARIANT_SCAFFOLD);
|
||||
#getDataPromise?: Promise<UmbRepositoryResponse<EntityModel>>;
|
||||
|
||||
#getDataPromise?: Promise<any>;
|
||||
// TODo: Optimize this so it uses either a App Language Context? [NL]
|
||||
#languageRepository = new UmbLanguageCollectionRepository(this);
|
||||
#languages = new UmbArrayState<UmbLanguageDetailModel>([], (x) => x.unique);
|
||||
|
||||
Reference in New Issue
Block a user