update ProblemDetailsModel
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { rest } from 'msw';
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/utils';
|
||||
import { ProblemDetails, RuntimeLevel, ServerStatus } from '@umbraco-cms/backend-api';
|
||||
import { ProblemDetailsModel, RuntimeLevel, ServerStatus } from '@umbraco-cms/backend-api';
|
||||
import { expect, test } from './test';
|
||||
|
||||
test.describe('installer tests', () => {
|
||||
@@ -62,7 +62,7 @@ test.describe('installer tests', () => {
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(400),
|
||||
ctx.json<ProblemDetails>({
|
||||
ctx.json<ProblemDetailsModel>({
|
||||
status: 400,
|
||||
type: 'validation',
|
||||
detail: 'Something went wrong',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { rest } from 'msw';
|
||||
import { umbracoPath } from '@umbraco-cms/utils';
|
||||
import { ProblemDetails, RuntimeLevel, ServerStatus } from '@umbraco-cms/backend-api';
|
||||
import { ProblemDetailsModel, RuntimeLevel, ServerStatus } from '@umbraco-cms/backend-api';
|
||||
import { expect, test } from './test';
|
||||
|
||||
test.describe('upgrader tests', () => {
|
||||
@@ -43,7 +43,7 @@ test.describe('upgrader tests', () => {
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(400),
|
||||
ctx.json<ProblemDetails>({
|
||||
ctx.json<ProblemDetailsModel>({
|
||||
status: 400,
|
||||
type: 'error',
|
||||
detail: 'Something went wrong',
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
EntityTreeItem,
|
||||
FolderTreeItem,
|
||||
PagedEntityTreeItem,
|
||||
ProblemDetails,
|
||||
ProblemDetailsModel,
|
||||
} from '@umbraco-cms/backend-api';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@@ -155,7 +155,7 @@ export interface DocumentBlueprintDetails {
|
||||
|
||||
export interface DataSourceResponse<T = undefined> {
|
||||
data?: T;
|
||||
error?: ProblemDetails;
|
||||
error?: ProblemDetailsModel;
|
||||
}
|
||||
|
||||
// TODO; figure out why we can't add UmbControllerHostInterface as host type
|
||||
@@ -166,15 +166,15 @@ export interface UmbTreeRepositoryFactory {
|
||||
export interface UmbTreeRepository {
|
||||
requestRootItems: () => Promise<{
|
||||
data: PagedEntityTreeItem | undefined;
|
||||
error: ProblemDetails | undefined;
|
||||
error: ProblemDetailsModel | undefined;
|
||||
}>;
|
||||
requestChildrenOf: (parentKey: string | null) => Promise<{
|
||||
data: PagedEntityTreeItem | undefined;
|
||||
error: ProblemDetails | undefined;
|
||||
error: ProblemDetailsModel | undefined;
|
||||
}>;
|
||||
requestItems: (keys: string[]) => Promise<{
|
||||
data: Array<EntityTreeItem> | undefined;
|
||||
error: ProblemDetails | undefined;
|
||||
error: ProblemDetailsModel | undefined;
|
||||
}>;
|
||||
rootItems: () => Promise<Observable<EntityTreeItem[]>>;
|
||||
childrenOf: (parentKey: string | null) => Promise<Observable<EntityTreeItem[]>>;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
UmbNotificationDefaultData,
|
||||
UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN,
|
||||
} from '@umbraco-cms/notification';
|
||||
import { ApiError, CancelablePromise, ProblemDetails } from '@umbraco-cms/backend-api';
|
||||
import { ApiError, CancelablePromise, ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
import { UmbController, UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
|
||||
@@ -33,13 +33,13 @@ export class UmbResourceController extends UmbController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the ProblemDetails object from an ApiError.
|
||||
* Extract the ProblemDetailsModel object from an ApiError.
|
||||
*
|
||||
* This assumes that all ApiErrors contain a ProblemDetails object in their body.
|
||||
* This assumes that all ApiErrors contain a ProblemDetailsModel object in their body.
|
||||
*/
|
||||
static toProblemDetails(error: unknown): ProblemDetails | undefined {
|
||||
static toProblemDetailsModel(error: unknown): ProblemDetailsModel | undefined {
|
||||
if (error instanceof ApiError) {
|
||||
const errorDetails = error.body as ProblemDetails;
|
||||
const errorDetails = error.body as ProblemDetailsModel;
|
||||
return errorDetails;
|
||||
} else if (error instanceof Error) {
|
||||
return {
|
||||
@@ -54,11 +54,11 @@ export class UmbResourceController extends UmbController {
|
||||
/**
|
||||
* Base execute function with a try/catch block and return a tuple with the result and the error.
|
||||
*/
|
||||
static async tryExecute<T>(promise: Promise<T>): Promise<{ data?: T; error?: ProblemDetails }> {
|
||||
static async tryExecute<T>(promise: Promise<T>): Promise<{ data?: T; error?: ProblemDetailsModel }> {
|
||||
try {
|
||||
return { data: await promise };
|
||||
} catch (e) {
|
||||
return { error: UmbResourceController.toProblemDetails(e) };
|
||||
return { error: UmbResourceController.toProblemDetailsModel(e) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,9 @@ export class UmbResourceController extends UmbController {
|
||||
* Wrap the {execute} function in a try/catch block and return the result.
|
||||
* If the executor function throws an error, then show the details in a notification.
|
||||
*/
|
||||
async tryExecuteAndNotify<T>(options?: UmbNotificationOptions<any>): Promise<{ data?: T; error?: ProblemDetails }> {
|
||||
async tryExecuteAndNotify<T>(
|
||||
options?: UmbNotificationOptions<any>
|
||||
): Promise<{ data?: T; error?: ProblemDetailsModel }> {
|
||||
const { data, error } = await UmbResourceController.tryExecute<T>(this.#promise);
|
||||
|
||||
if (error) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TemplateTreeDataSource } from '.';
|
||||
import { ProblemDetails, TemplateResource } from '@umbraco-cms/backend-api';
|
||||
import { ProblemDetailsModel, TemplateResource } from '@umbraco-cms/backend-api';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/resources';
|
||||
|
||||
@@ -38,7 +38,7 @@ export class TemplateTreeServerDataSource implements TemplateTreeDataSource {
|
||||
*/
|
||||
async getChildrenOf(parentKey: string | null) {
|
||||
if (!parentKey) {
|
||||
const error: ProblemDetails = { title: 'Parent key is missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Parent key is missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export class TemplateTreeServerDataSource implements TemplateTreeDataSource {
|
||||
*/
|
||||
async getItems(keys: Array<string>) {
|
||||
if (keys) {
|
||||
const error: ProblemDetails = { title: 'Keys are missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Keys are missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { UmbTemplateTreeStore, UMB_TEMPLATE_TREE_STORE_CONTEXT_TOKEN } from './t
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { ProblemDetails } from '@umbraco-cms/backend-api';
|
||||
import { ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
import type { UmbTreeRepository } from '@umbraco-cms/models';
|
||||
|
||||
// Move to documentation / JSdoc
|
||||
@@ -61,7 +61,7 @@ export class UmbTemplateTreeRepository implements UmbTreeRepository {
|
||||
await this.#init;
|
||||
|
||||
if (!parentKey) {
|
||||
const error: ProblemDetails = { title: 'Parent key is missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Parent key is missing' };
|
||||
return { data: undefined, error };
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export class UmbTemplateTreeRepository implements UmbTreeRepository {
|
||||
await this.#init;
|
||||
|
||||
if (!keys) {
|
||||
const error: ProblemDetails = { title: 'Keys are missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Keys are missing' };
|
||||
return { data: undefined, error };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { TemplateDetailDataSource } from '.';
|
||||
import { ProblemDetails, Template, TemplateResource } from '@umbraco-cms/backend-api';
|
||||
import { ProblemDetailsModel, Template, TemplateResource } from '@umbraco-cms/backend-api';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/resources';
|
||||
|
||||
@@ -88,7 +88,7 @@ export class UmbTemplateDetailServerDataSource implements TemplateDetailDataSour
|
||||
*/
|
||||
async update(template: Template) {
|
||||
if (!template.key) {
|
||||
const error: ProblemDetails = { title: 'Template key is missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Template key is missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ export class UmbTemplateDetailServerDataSource implements TemplateDetailDataSour
|
||||
*/
|
||||
async delete(key: string) {
|
||||
if (!key) {
|
||||
const error: ProblemDetails = { title: 'Key is missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Key is missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UmbTemplateTreeStore, UMB_TEMPLATE_TREE_STORE_CONTEXT_TOKEN } from '../../tree/data/template.tree.store';
|
||||
import { UmbTemplateDetailStore, UMB_TEMPLATE_DETAIL_STORE_CONTEXT_TOKEN } from './template.detail.store';
|
||||
import { UmbTemplateDetailServerDataSource } from './sources/template.detail.server.data';
|
||||
import { ProblemDetails, Template } from '@umbraco-cms/backend-api';
|
||||
import { ProblemDetailsModel, Template } from '@umbraco-cms/backend-api';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
@@ -11,7 +11,6 @@ import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '
|
||||
// element -> context -> repository -> (store) -> data source
|
||||
// All methods should be async and return a promise. Some methods might return an observable as part of the promise response.
|
||||
export class UmbTemplateDetailRepository {
|
||||
|
||||
#host: UmbControllerHostInterface;
|
||||
#dataSource: UmbTemplateDetailServerDataSource;
|
||||
#detailStore?: UmbTemplateDetailStore;
|
||||
@@ -63,7 +62,7 @@ export class UmbTemplateDetailRepository {
|
||||
// TODO: should we show a notification if the parent key is missing?
|
||||
// Investigate what is best for Acceptance testing, cause in that perspective a thrown error might be the best choice?
|
||||
if (!parentKey) {
|
||||
const error: ProblemDetails = { title: 'Parent key is missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Parent key is missing' };
|
||||
return { data: undefined, error };
|
||||
}
|
||||
|
||||
@@ -76,7 +75,7 @@ export class UmbTemplateDetailRepository {
|
||||
// TODO: should we show a notification if the key is missing?
|
||||
// Investigate what is best for Acceptance testing, cause in that perspective a thrown error might be the best choice?
|
||||
if (!key) {
|
||||
const error: ProblemDetails = { title: 'Key is missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Key is missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
@@ -89,7 +88,7 @@ export class UmbTemplateDetailRepository {
|
||||
// TODO: should we show a notification if the template is missing?
|
||||
// Investigate what is best for Acceptance testing, cause in that perspective a thrown error might be the best choice?
|
||||
if (!template) {
|
||||
const error: ProblemDetails = { title: 'Template is missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Template is missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
@@ -114,7 +113,7 @@ export class UmbTemplateDetailRepository {
|
||||
// TODO: should we show a notification if the template is missing?
|
||||
// Investigate what is best for Acceptance testing, cause in that perspective a thrown error might be the best choice?
|
||||
if (!template || !template.key) {
|
||||
const error: ProblemDetails = { title: 'Template is missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Template is missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
@@ -140,7 +139,7 @@ export class UmbTemplateDetailRepository {
|
||||
|
||||
// TODO: should we show a notification if the key is missing?
|
||||
if (!key) {
|
||||
const error: ProblemDetails = { title: 'Key is missing' };
|
||||
const error: ProblemDetailsModel = { title: 'Key is missing' };
|
||||
return { error };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { rest } from 'msw';
|
||||
import { DatabaseInstall, Install, InstallSettings, ProblemDetails, TelemetryLevel } from '@umbraco-cms/backend-api';
|
||||
import {
|
||||
DatabaseInstall,
|
||||
Install,
|
||||
InstallSettings,
|
||||
ProblemDetailsModel,
|
||||
TelemetryLevel,
|
||||
} from '@umbraco-cms/backend-api';
|
||||
import { umbracoPath } from '@umbraco-cms/utils';
|
||||
|
||||
export const handlers = [
|
||||
@@ -78,7 +84,7 @@ export const handlers = [
|
||||
if (body.name === 'validate') {
|
||||
return res(
|
||||
ctx.status(400),
|
||||
ctx.json<ProblemDetails>({
|
||||
ctx.json<ProblemDetailsModel>({
|
||||
type: 'connection',
|
||||
status: 400,
|
||||
detail: 'Database connection failed',
|
||||
@@ -100,7 +106,7 @@ export const handlers = [
|
||||
// Respond with a 200 status code
|
||||
ctx.status(400),
|
||||
ctx.delay(1000),
|
||||
ctx.json<ProblemDetails>({
|
||||
ctx.json<ProblemDetailsModel>({
|
||||
type: 'validation',
|
||||
status: 400,
|
||||
detail: 'Something went wrong',
|
||||
|
||||
@@ -3,7 +3,7 @@ import { css, CSSResultGroup, html, nothing } from 'lit';
|
||||
import { customElement, property, query, state } from 'lit/decorators.js';
|
||||
|
||||
import { UmbInstallerContext, UMB_INSTALLER_CONTEXT_TOKEN } from '../installer.context';
|
||||
import { DatabaseInstall, DatabaseSettings, InstallResource, ProblemDetails } from '@umbraco-cms/backend-api';
|
||||
import { DatabaseInstall, DatabaseSettings, InstallResource, ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
import { tryExecute } from '@umbraco-cms/resources';
|
||||
|
||||
@@ -251,7 +251,7 @@ export class UmbInstallerDatabaseElement extends UmbLitElement {
|
||||
history.replaceState(null, '', '/content');
|
||||
}
|
||||
|
||||
private _handleRejected(e: ProblemDetails) {
|
||||
private _handleRejected(e: ProblemDetailsModel) {
|
||||
this._installerContext?.setInstallStatus(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { css, CSSResultGroup, html, nothing } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
|
||||
import { UmbInstallerContext, UMB_INSTALLER_CONTEXT_TOKEN } from '../installer.context';
|
||||
import { ProblemDetails } from '@umbraco-cms/backend-api';
|
||||
import { ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
|
||||
@customElement('umb-installer-error')
|
||||
@@ -27,7 +27,7 @@ export class UmbInstallerErrorElement extends UmbLitElement {
|
||||
];
|
||||
|
||||
@state()
|
||||
_error?: ProblemDetails;
|
||||
_error?: ProblemDetailsModel;
|
||||
|
||||
private _installerContext?: UmbInstallerContext;
|
||||
|
||||
@@ -55,7 +55,7 @@ export class UmbInstallerErrorElement extends UmbLitElement {
|
||||
this._installerContext?.reset();
|
||||
}
|
||||
|
||||
private _renderError(error: ProblemDetails) {
|
||||
private _renderError(error: ProblemDetailsModel) {
|
||||
return html`
|
||||
<p>Description: ${error.title}</p>
|
||||
${error.errors ? this._renderErrors(error.errors) : nothing}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { Install, InstallResource, InstallSettings, ProblemDetails, TelemetryLevel } from '@umbraco-cms/backend-api';
|
||||
import {
|
||||
Install,
|
||||
InstallResource,
|
||||
InstallSettings,
|
||||
ProblemDetailsModel,
|
||||
TelemetryLevel,
|
||||
} from '@umbraco-cms/backend-api';
|
||||
import { tryExecute } from '@umbraco-cms/resources';
|
||||
import { UmbContextToken } from '@umbraco-cms/context-api';
|
||||
import { ObjectState, NumberState } from '@umbraco-cms/observable-api';
|
||||
@@ -23,7 +29,7 @@ export class UmbInstallerContext {
|
||||
private _settings = new ObjectState<InstallSettings | undefined>(undefined);
|
||||
public readonly settings = this._settings.asObservable();
|
||||
|
||||
private _installStatus = new ObjectState<ProblemDetails | null>(null);
|
||||
private _installStatus = new ObjectState<ProblemDetailsModel | null>(null);
|
||||
public readonly installStatus = this._installStatus.asObservable();
|
||||
|
||||
constructor() {
|
||||
@@ -43,10 +49,10 @@ export class UmbInstallerContext {
|
||||
/**
|
||||
* Observable method to get the install status in the installation process
|
||||
* @public
|
||||
* @return {*} {(Observable<ProblemDetails | null>)}
|
||||
* @return {*} {(Observable<ProblemDetailsModel | null>)}
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public installStatusChanges(): Observable<ProblemDetails | null> {
|
||||
public installStatusChanges(): Observable<ProblemDetailsModel | null> {
|
||||
return this.installStatus;
|
||||
}
|
||||
|
||||
@@ -101,10 +107,10 @@ export class UmbInstallerContext {
|
||||
/**
|
||||
* Set the install status
|
||||
* @public
|
||||
* @param {(ProblemDetails | null)} status
|
||||
* @param {(ProblemDetailsModel | null)} status
|
||||
* @memberof UmbInstallerContext
|
||||
*/
|
||||
public setInstallStatus(status: ProblemDetails | null): void {
|
||||
public setInstallStatus(status: ProblemDetailsModel | null): void {
|
||||
this._installStatus.next(status);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user