Added mock API data/handler

This commit is contained in:
leekelleher
2024-02-06 10:55:16 +00:00
parent d1449d47fc
commit 1e6736d192
3 changed files with 26 additions and 0 deletions

View File

@@ -36,6 +36,7 @@ import { handlers as partialViewHandlers } from './handlers/partial-view/index.j
import { handlers as tagHandlers } from './handlers/tag-handlers.js';
import { handlers as configHandlers } from './handlers/config.handlers.js';
import { handlers as scriptHandlers } from './handlers/script/index.js';
import { handlers as dynamicRootHandlers } from './handlers/dynamic-root.handlers.js';
const handlers = [
serverHandlers.serverInformationHandler,
@@ -46,6 +47,7 @@ const handlers = [
...dictionaryHandlers,
...documentHandlers,
...documentTypeHandlers,
...dynamicRootHandlers,
...examineManagementHandlers,
...healthCheckHandlers,
...installHandlers,

View File

@@ -227,6 +227,15 @@ export const data: Array<UmbMockDataTypeModel> = [
value: {
type: 'content',
id: null,
dynamicRoot: {
originAlias: 'Root',
querySteps: [
{
alias: 'FurthestAncestorOrSelf',
anyOfDocTypeKeys: ['all-property-editors-document-type-id'],
},
],
},
},
},
{

View File

@@ -0,0 +1,15 @@
import { umbDocumentMockDb } from '../data/document/document.db.js';
import type { DynamicRootRequestModel } from '@umbraco-cms/backoffice/backend-api';
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
const { rest } = window.MockServiceWorker;
export const handlers = [
rest.post<DynamicRootRequestModel>(umbracoPath('/dynamic-root/query'), async (req, res, ctx) => {
const response = umbDocumentMockDb.tree
.getRoot()
.items.map((item) => item.id)
.slice(0, 1);
return res(ctx.status(200), ctx.json(response));
}),
];