remove type cast

This commit is contained in:
Mads Rasmussen
2023-12-07 16:37:30 +01:00
parent ba3359f9c4
commit 7045dcb078
10 changed files with 19 additions and 17 deletions

View File

@@ -2,7 +2,6 @@ const { rest } = window.MockServiceWorker;
import { RestHandler, MockedRequest, DefaultBodyType } from 'msw'; import { RestHandler, MockedRequest, DefaultBodyType } from 'msw';
import { umbPartialViewsData, umbPartialViewsTreeData } from '../data/partial-views.data.js'; import { umbPartialViewsData, umbPartialViewsTreeData } from '../data/partial-views.data.js';
import { umbracoPath } from '@umbraco-cms/backoffice/utils'; import { umbracoPath } from '@umbraco-cms/backoffice/utils';
import { CreateTextFileViewModelBaseModel } from '@umbraco-cms/backoffice/backend-api';
const treeHandlers = [ const treeHandlers = [
rest.get(umbracoPath('/tree/partial-view/root'), (req, res, ctx) => { rest.get(umbracoPath('/tree/partial-view/root'), (req, res, ctx) => {
@@ -35,8 +34,8 @@ const detailHandlers: RestHandler<MockedRequest<DefaultBodyType>>[] = [
return res(ctx.status(200), ctx.json(response)); return res(ctx.status(200), ctx.json(response));
}), }),
rest.post(umbracoPath('/partial-view'), (req, res, ctx) => { rest.post(umbracoPath('/partial-view'), async (req, res, ctx) => {
const requestBody = req.json() as CreateTextFileViewModelBaseModel; const requestBody = await req.json();
if (!requestBody) return res(ctx.status(400, 'no body found')); if (!requestBody) return res(ctx.status(400, 'no body found'));
const response = umbPartialViewsData.insertPartialView(requestBody); const response = umbPartialViewsData.insertPartialView(requestBody);
return res(ctx.status(200), ctx.json(response)); return res(ctx.status(200), ctx.json(response));
@@ -49,8 +48,8 @@ const detailHandlers: RestHandler<MockedRequest<DefaultBodyType>>[] = [
return res(ctx.status(200)); return res(ctx.status(200));
}), }),
rest.put(umbracoPath('/partial-view'), (req, res, ctx) => { rest.put(umbracoPath('/partial-view'), async (req, res, ctx) => {
const requestBody = req.json() as CreateTextFileViewModelBaseModel; const requestBody = await req.json();
if (!requestBody) return res(ctx.status(400, 'no body found')); if (!requestBody) return res(ctx.status(400, 'no body found'));
umbPartialViewsData.updateData(requestBody); umbPartialViewsData.updateData(requestBody);
return res(ctx.status(200)); return res(ctx.status(200));

View File

@@ -1,3 +1,4 @@
import { UmbDocumentTypeTreeItemModel } from './types.js';
import type { UmbTreeDataSource } from '@umbraco-cms/backoffice/tree'; import type { UmbTreeDataSource } from '@umbraco-cms/backoffice/tree';
import { DocumentTypeResource } from '@umbraco-cms/backoffice/backend-api'; import { DocumentTypeResource } from '@umbraco-cms/backoffice/backend-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
@@ -9,7 +10,7 @@ import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
* @class UmbDocumentTypeTreeServerDataSource * @class UmbDocumentTypeTreeServerDataSource
* @implements {UmbTreeDataSource} * @implements {UmbTreeDataSource}
*/ */
export class UmbDocumentTypeTreeServerDataSource implements UmbTreeDataSource { export class UmbDocumentTypeTreeServerDataSource implements UmbTreeDataSource<UmbDocumentTypeTreeItemModel> {
#host: UmbControllerHost; #host: UmbControllerHost;
/** /**

View File

@@ -36,7 +36,7 @@ export class UmbDocumentTreeServerDataSource implements UmbTreeDataSource<Entity
* @return {*} * @return {*}
* @memberof UmbDocumentTreeServerDataSource * @memberof UmbDocumentTreeServerDataSource
*/ */
async getChildrenOf(parentId: string | null): Promise<any> { async getChildrenOf(parentId: string | null) {
/* TODO: should we make getRootItems() internal /* TODO: should we make getRootItems() internal
so it only is a server concern that there are two endpoints? */ so it only is a server concern that there are two endpoints? */
if (parentId === null) { if (parentId === null) {

View File

@@ -1,3 +1,4 @@
import { UmbMediaTypeTreeItemModel } from './types.js';
import type { UmbTreeDataSource } from '@umbraco-cms/backoffice/tree'; import type { UmbTreeDataSource } from '@umbraco-cms/backoffice/tree';
import { MediaTypeResource } from '@umbraco-cms/backoffice/backend-api'; import { MediaTypeResource } from '@umbraco-cms/backoffice/backend-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
@@ -9,7 +10,7 @@ import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
* @class UmbMediaTypeTreeServerDataSource * @class UmbMediaTypeTreeServerDataSource
* @implements {UmbTreeDataSource} * @implements {UmbTreeDataSource}
*/ */
export class UmbMediaTypeTreeServerDataSource implements UmbTreeDataSource { export class UmbMediaTypeTreeServerDataSource implements UmbTreeDataSource<UmbMediaTypeTreeItemModel> {
#host: UmbControllerHost; #host: UmbControllerHost;
/** /**

View File

@@ -36,7 +36,7 @@ export class UmbMediaTreeServerDataSource implements UmbTreeDataSource<EntityTre
* @return {*} * @return {*}
* @memberof UmbMediaTreeServerDataSource * @memberof UmbMediaTreeServerDataSource
*/ */
async getChildrenOf(parentId: string | null): Promise<any> { async getChildrenOf(parentId: string | null) {
/* TODO: should we make getRootItems() internal /* TODO: should we make getRootItems() internal
so it only is a server concern that there are two endpoints? */ so it only is a server concern that there are two endpoints? */
if (parentId === null) { if (parentId === null) {

View File

@@ -36,7 +36,7 @@ export class UmbMemberGroupTreeServerDataSource implements UmbTreeDataSource<Ent
* @return {*} * @return {*}
* @memberof UmbMemberGroupTreeServerDataSource * @memberof UmbMemberGroupTreeServerDataSource
*/ */
async getChildrenOf(parentId: string | null): Promise<any> { async getChildrenOf(parentId: string | null) {
/* TODO: should we make getRootItems() internal /* TODO: should we make getRootItems() internal
so it only is a server concern that there are two endpoints? */ so it only is a server concern that there are two endpoints? */
if (parentId === null) { if (parentId === null) {

View File

@@ -36,7 +36,7 @@ export class UmbMemberTypeTreeServerDataSource implements UmbTreeDataSource<Enti
* @return {*} * @return {*}
* @memberof UmbMemberTypeTreeServerDataSource * @memberof UmbMemberTypeTreeServerDataSource
*/ */
async getChildrenOf(parentId: string | null): Promise<any> { async getChildrenOf(parentId: string | null) {
/* TODO: should we make getRootItems() internal /* TODO: should we make getRootItems() internal
so it only is a server concern that there are two endpoints? */ so it only is a server concern that there are two endpoints? */
if (parentId === null) { if (parentId === null) {

View File

@@ -25,7 +25,7 @@ export class UmbMemberTreeServerDataSource implements UmbTreeDataSource<EntityTr
* @return {*} * @return {*}
* @memberof UmbMemberTreeServerDataSource * @memberof UmbMemberTreeServerDataSource
*/ */
async getRootItems(): Promise<any> { async getRootItems() {
alert('not implemented'); alert('not implemented');
//return tryExecuteAndNotify(this.#host, MemberResource.getTreeMemberRoot({})); //return tryExecuteAndNotify(this.#host, MemberResource.getTreeMemberRoot({}));
} }
@@ -36,7 +36,7 @@ export class UmbMemberTreeServerDataSource implements UmbTreeDataSource<EntityTr
* @return {*} * @return {*}
* @memberof UmbMemberTreeServerDataSource * @memberof UmbMemberTreeServerDataSource
*/ */
async getChildrenOf(parentId: string | null): Promise<any> { async getChildrenOf(parentId: string | null) {
alert('not implemented'); alert('not implemented');
/* TODO: should we make getRootItems() internal /* TODO: should we make getRootItems() internal
so it only is a server concern that there are two endpoints? */ so it only is a server concern that there are two endpoints? */

View File

@@ -36,7 +36,7 @@ export class UmbRelationTypeTreeServerDataSource implements UmbTreeDataSource<En
* @return {*} * @return {*}
* @memberof UmbRelationTypeTreeServerDataSource * @memberof UmbRelationTypeTreeServerDataSource
*/ */
async getChildrenOf(parentId: string | null): Promise<any> { async getChildrenOf(parentId: string | null) {
/* TODO: should we make getRootItems() internal /* TODO: should we make getRootItems() internal
so it only is a server concern that there are two endpoints? */ so it only is a server concern that there are two endpoints? */
if (parentId === null) { if (parentId === null) {

View File

@@ -1,4 +1,5 @@
import type { UmbEntityTreeItemModel, UmbTreeDataSource } from '@umbraco-cms/backoffice/tree'; import { UmbTemplateTreeItemModel } from './types.js';
import type { UmbTreeDataSource } from '@umbraco-cms/backoffice/tree';
import { TemplateResource } from '@umbraco-cms/backoffice/backend-api'; import { TemplateResource } from '@umbraco-cms/backoffice/backend-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources'; import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
@@ -9,7 +10,7 @@ import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
* @class UmbTemplateTreeServerDataSource * @class UmbTemplateTreeServerDataSource
* @implements {UmbTreeDataSource} * @implements {UmbTreeDataSource}
*/ */
export class UmbTemplateTreeServerDataSource implements UmbTreeDataSource<UmbEntityTreeItemModel> { export class UmbTemplateTreeServerDataSource implements UmbTreeDataSource<UmbTemplateTreeItemModel> {
#host: UmbControllerHost; #host: UmbControllerHost;
/** /**
@@ -36,7 +37,7 @@ export class UmbTemplateTreeServerDataSource implements UmbTreeDataSource<UmbEnt
* @return {*} * @return {*}
* @memberof UmbTemplateTreeServerDataSource * @memberof UmbTemplateTreeServerDataSource
*/ */
async getChildrenOf(parentId: string | null): Promise<any> { async getChildrenOf(parentId: string | null) {
/* TODO: should we make getRootItems() internal /* TODO: should we make getRootItems() internal
so it only is a server concern that there are two endpoints? */ so it only is a server concern that there are two endpoints? */
if (parentId === null) { if (parentId === null) {