add new api handler for upgrader

This commit is contained in:
Jacob Overgaard
2022-07-27 13:50:28 +02:00
parent f7848d43b3
commit 0a986f10f6
3 changed files with 71 additions and 0 deletions

View File

@@ -19,6 +19,12 @@ export interface paths {
"/server/version": {
get: operations["GetVersion"];
};
"/upgrade/settings": {
get: operations["GetUpgradeSettings"];
};
"/upgrade/authorize": {
post: operations["PostUpgradeAuthorize"];
};
"/user": {
get: operations["GetUser"];
};
@@ -107,6 +113,13 @@ export interface components {
VersionResponse: {
version: string;
};
UpgradeSettingsResponse: {
currentState: string;
newState: string;
newVersion: string;
oldVersion: string;
reportUrl: string;
};
UserResponse: {
username: string;
role: string;
@@ -207,6 +220,35 @@ export interface operations {
};
};
};
GetUpgradeSettings: {
responses: {
/** 200 response */
200: {
content: {
"application/json": components["schemas"]["UpgradeSettingsResponse"];
};
};
/** default response */
default: {
content: {
"application/json": components["schemas"]["ProblemDetails"];
};
};
};
};
PostUpgradeAuthorize: {
parameters: {};
responses: {
/** 201 response */
201: unknown;
/** 400 response */
400: {
content: {
"application/json": components["schemas"]["ProblemDetails"];
};
};
};
};
GetUser: {
responses: {
/** 200 response */

View File

@@ -7,6 +7,7 @@ export type ProblemDetails = components['schemas']['ProblemDetails'];
export type UserResponse = components['schemas']['UserResponse'];
export type AllowedSectionsResponse = components['schemas']['AllowedSectionsResponse'];
export type UmbracoInstaller = components['schemas']['InstallSettingsResponse'];
export type UmbracoUpgrader = components['schemas']['UpgradeSettingsResponse'];
// Models
export type UmbracoPerformInstallDatabaseConfiguration = components['schemas']['InstallSetupDatabaseConfiguration'];

View File

@@ -0,0 +1,28 @@
import { rest } from 'msw';
import { PostInstallRequest, UmbracoUpgrader } from '../../core/models';
export const handlers = [
rest.get('/umbraco/backoffice/upgrade/settings', (_req, res, ctx) => {
return res(
// Respond with a 200 status code
ctx.status(200),
ctx.json<UmbracoUpgrader>({
currentState: '2b20c6e7',
newState: '2b20c6e8',
oldVersion: '13.0.0',
newVersion: '13.1.0',
reportUrl: 'https://our.umbraco.com/download/releases/1000',
})
);
}),
rest.post<PostInstallRequest>('/umbraco/backoffice/upgrade/authorize', async (_req, res, ctx) => {
await new Promise((resolve) => setTimeout(resolve, (Math.random() + 1) * 1000)); // simulate a delay of 1-2 seconds
return res(
// Respond with a 200 status code
ctx.status(201)
);
}),
];