revamp init and version responses into ServerController
This commit is contained in:
@@ -3,38 +3,6 @@ info:
|
||||
title: umbraco-backoffice-api
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/init:
|
||||
get:
|
||||
operationId: GetInit
|
||||
responses:
|
||||
'200':
|
||||
description: 200 response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/InitResponse'
|
||||
default:
|
||||
description: default response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ProblemDetails'
|
||||
/version:
|
||||
get:
|
||||
operationId: GetVersion
|
||||
responses:
|
||||
'200':
|
||||
description: 200 response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/VersionResponse'
|
||||
default:
|
||||
description: default response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ProblemDetails'
|
||||
/install:
|
||||
get:
|
||||
operationId: GetInstall
|
||||
@@ -82,6 +50,38 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ProblemDetails'
|
||||
/server/status:
|
||||
get:
|
||||
operationId: GetStatus
|
||||
responses:
|
||||
'200':
|
||||
description: 200 response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/StatusResponse'
|
||||
default:
|
||||
description: default response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ProblemDetails'
|
||||
/server/version:
|
||||
get:
|
||||
operationId: GetVersion
|
||||
responses:
|
||||
'200':
|
||||
description: 200 response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/VersionResponse'
|
||||
default:
|
||||
description: default response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ProblemDetails'
|
||||
/user:
|
||||
get:
|
||||
operationId: GetUser
|
||||
@@ -147,39 +147,6 @@ paths:
|
||||
$ref: '#/components/schemas/ProblemDetails'
|
||||
components:
|
||||
schemas:
|
||||
InitResponse:
|
||||
type: object
|
||||
properties:
|
||||
installed:
|
||||
type: boolean
|
||||
required:
|
||||
- installed
|
||||
ProblemDetails:
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
status:
|
||||
type: number
|
||||
format: float
|
||||
title:
|
||||
type: string
|
||||
detail:
|
||||
type: string
|
||||
instance:
|
||||
type: string
|
||||
errors:
|
||||
type: object
|
||||
required:
|
||||
- type
|
||||
- status
|
||||
VersionResponse:
|
||||
type: object
|
||||
properties:
|
||||
version:
|
||||
type: string
|
||||
required:
|
||||
- version
|
||||
ConsentLevel:
|
||||
type: string
|
||||
enum:
|
||||
@@ -311,6 +278,39 @@ components:
|
||||
- subscribeToNewsletter
|
||||
- telemetryLevel
|
||||
- database
|
||||
ProblemDetails:
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
status:
|
||||
type: number
|
||||
format: float
|
||||
title:
|
||||
type: string
|
||||
detail:
|
||||
type: string
|
||||
instance:
|
||||
type: string
|
||||
errors:
|
||||
type: object
|
||||
required:
|
||||
- type
|
||||
- status
|
||||
StatusResponse:
|
||||
type: object
|
||||
properties:
|
||||
installed:
|
||||
type: boolean
|
||||
required:
|
||||
- installed
|
||||
VersionResponse:
|
||||
type: object
|
||||
properties:
|
||||
version:
|
||||
type: string
|
||||
required:
|
||||
- version
|
||||
UserResponse:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
@@ -4,12 +4,6 @@
|
||||
*/
|
||||
|
||||
export interface paths {
|
||||
"/init": {
|
||||
get: operations["GetInit"];
|
||||
};
|
||||
"/version": {
|
||||
get: operations["GetVersion"];
|
||||
};
|
||||
"/install": {
|
||||
get: operations["GetInstall"];
|
||||
post: operations["PostInstall"];
|
||||
@@ -17,6 +11,12 @@ export interface paths {
|
||||
"/install/database/validate": {
|
||||
post: operations["PostInstallValidateDatabase"];
|
||||
};
|
||||
"/server/status": {
|
||||
get: operations["GetStatus"];
|
||||
};
|
||||
"/server/version": {
|
||||
get: operations["GetVersion"];
|
||||
};
|
||||
"/user": {
|
||||
get: operations["GetUser"];
|
||||
};
|
||||
@@ -33,21 +33,6 @@ export interface paths {
|
||||
|
||||
export interface components {
|
||||
schemas: {
|
||||
InitResponse: {
|
||||
installed: boolean;
|
||||
};
|
||||
ProblemDetails: {
|
||||
type: string;
|
||||
/** Format: float */
|
||||
status: number;
|
||||
title?: string;
|
||||
detail?: string;
|
||||
instance?: string;
|
||||
errors?: { [key: string]: unknown };
|
||||
};
|
||||
VersionResponse: {
|
||||
version: string;
|
||||
};
|
||||
/** @enum {string} */
|
||||
ConsentLevel: "Minimal" | "Basic" | "Detailed";
|
||||
TelemetryModel: {
|
||||
@@ -96,6 +81,21 @@ export interface components {
|
||||
telemetryLevel: components["schemas"]["ConsentLevel"];
|
||||
database: components["schemas"]["UmbracoPerformInstallDatabaseConfiguration"];
|
||||
};
|
||||
ProblemDetails: {
|
||||
type: string;
|
||||
/** Format: float */
|
||||
status: number;
|
||||
title?: string;
|
||||
detail?: string;
|
||||
instance?: string;
|
||||
errors?: { [key: string]: unknown };
|
||||
};
|
||||
StatusResponse: {
|
||||
installed: boolean;
|
||||
};
|
||||
VersionResponse: {
|
||||
version: string;
|
||||
};
|
||||
UserResponse: {
|
||||
username: string;
|
||||
role: string;
|
||||
@@ -112,38 +112,6 @@ export interface components {
|
||||
}
|
||||
|
||||
export interface operations {
|
||||
GetInit: {
|
||||
responses: {
|
||||
/** 200 response */
|
||||
200: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["InitResponse"];
|
||||
};
|
||||
};
|
||||
/** default response */
|
||||
default: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["ProblemDetails"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
GetVersion: {
|
||||
responses: {
|
||||
/** 200 response */
|
||||
200: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["VersionResponse"];
|
||||
};
|
||||
};
|
||||
/** default response */
|
||||
default: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["ProblemDetails"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
GetInstall: {
|
||||
responses: {
|
||||
/** 200 response */
|
||||
@@ -190,6 +158,38 @@ export interface operations {
|
||||
};
|
||||
};
|
||||
};
|
||||
GetStatus: {
|
||||
responses: {
|
||||
/** 200 response */
|
||||
200: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["StatusResponse"];
|
||||
};
|
||||
};
|
||||
/** default response */
|
||||
default: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["ProblemDetails"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
GetVersion: {
|
||||
responses: {
|
||||
/** 200 response */
|
||||
200: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["VersionResponse"];
|
||||
};
|
||||
};
|
||||
/** default response */
|
||||
default: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["ProblemDetails"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
GetUser: {
|
||||
responses: {
|
||||
/** 200 response */
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'router-slot';
|
||||
import '@umbraco-ui/uui-css/dist/uui-css.css';
|
||||
import 'router-slot';
|
||||
|
||||
import { UUIIconRegistryEssential } from '@umbraco-ui/uui';
|
||||
import { css, html, LitElement } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
|
||||
import { getInitStatus } from './core/api/fetcher';
|
||||
import { getServerStatus } from './core/api/fetcher';
|
||||
import { UmbContextProviderMixin } from './core/context';
|
||||
import { UmbExtensionManifest, UmbExtensionManifestCore, UmbExtensionRegistry } from './core/extension';
|
||||
import { internalManifests } from './temp-internal-manifests';
|
||||
@@ -46,7 +46,7 @@ export class UmbApp extends UmbContextProviderMixin(LitElement) {
|
||||
this._setup();
|
||||
}
|
||||
|
||||
private async _setup () {
|
||||
private async _setup() {
|
||||
this._iconRegistry.attach(this);
|
||||
this.provideContext('umbExtensionRegistry', this._extensionRegistry);
|
||||
|
||||
@@ -58,14 +58,14 @@ export class UmbApp extends UmbContextProviderMixin(LitElement) {
|
||||
|
||||
private async _setInitStatus() {
|
||||
try {
|
||||
const { data } = await getInitStatus({});
|
||||
const { data } = await getServerStatus({});
|
||||
this._isInstalled = data.installed;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
private _redirect () {
|
||||
private _redirect() {
|
||||
if (!this._isInstalled) {
|
||||
history.pushState(null, '', '/install');
|
||||
return;
|
||||
@@ -87,10 +87,10 @@ export class UmbApp extends UmbContextProviderMixin(LitElement) {
|
||||
const res = await fetch('/umbraco/backoffice/manifests');
|
||||
const { manifests } = await res.json();
|
||||
manifests.forEach((manifest: UmbExtensionManifest) => this._extensionRegistry.register(manifest));
|
||||
};
|
||||
}
|
||||
|
||||
private async _registerInternalManifests() {
|
||||
// TODO: where do we get these from?
|
||||
// TODO: where do we get these from?
|
||||
internalManifests.forEach((manifest: UmbExtensionManifestCore) =>
|
||||
this._extensionRegistry.register<UmbExtensionManifestCore>(manifest)
|
||||
);
|
||||
|
||||
@@ -8,7 +8,8 @@ fetcher.configure({
|
||||
baseUrl: '/umbraco/backoffice',
|
||||
});
|
||||
|
||||
export const getInitStatus = fetcher.path('/init').method('get').create();
|
||||
export const getServerStatus = fetcher.path('/server/status').method('get').create();
|
||||
export const getServerVersion = fetcher.path('/server/version').method('get').create();
|
||||
export const getUser = fetcher.path('/user').method('get').create();
|
||||
export const postUserLogin = fetcher.path('/user/login').method('post').create();
|
||||
export const postUserLogout = fetcher.path('/user/logout').method('post').create();
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import { components } from '../../../schemas/generated-schema';
|
||||
|
||||
export type PostInstallRequest = components['schemas']['UmbracoPerformInstallRequest'];
|
||||
export type InitResponse = components['schemas']['InitResponse'];
|
||||
export type StatusResponse = components['schemas']['StatusResponse'];
|
||||
export type VersionResponse = components['schemas']['VersionResponse'];
|
||||
export type ProblemDetails = components['schemas']['ProblemDetails'];
|
||||
export type UserResponse = components['schemas']['UserResponse'];
|
||||
export type AllowedSectionsResponse = components['schemas']['AllowedSectionsResponse'];
|
||||
export type UmbracoInstaller = components['schemas']['UmbracoInstaller'];
|
||||
|
||||
export type UmbracoPerformInstallRequest = components['schemas']['UmbracoPerformInstallRequest'];
|
||||
|
||||
export type UmbracoPerformInstallDatabaseConfiguration =
|
||||
components['schemas']['UmbracoPerformInstallDatabaseConfiguration'];
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { rest } from 'msw';
|
||||
import { InitResponse } from '../core/models';
|
||||
|
||||
import { StatusResponse } from '../core/models';
|
||||
import { handlers as contentHandlers } from './domains/content.handlers';
|
||||
import { handlers as installHandlers } from './domains/install.handlers';
|
||||
import { handlers as manifestsHandlers } from './domains/manifests.handlers';
|
||||
@@ -11,7 +12,7 @@ export const handlers = [
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(200),
|
||||
ctx.json<InitResponse>({
|
||||
ctx.json<StatusResponse>({
|
||||
installed: import.meta.env.VITE_UMBRACO_INSTALL_STATUS !== 'false',
|
||||
})
|
||||
);
|
||||
|
||||
@@ -1,34 +1,9 @@
|
||||
import './installer';
|
||||
import './server';
|
||||
import './user';
|
||||
|
||||
import { api, body, defaultResponse, endpoint, response } from '@airtasker/spot';
|
||||
|
||||
import { InitResponse, ProblemDetails, VersionResponse } from './models';
|
||||
import { api } from '@airtasker/spot';
|
||||
|
||||
/* eslint-disable */
|
||||
@api({ name: 'umbraco-backoffice-api', version: '1.0.0' })
|
||||
class Api {}
|
||||
|
||||
@endpoint({
|
||||
method: 'GET',
|
||||
path: '/init',
|
||||
})
|
||||
class GetInit {
|
||||
@response({ status: 200 })
|
||||
success(@body body: InitResponse) {}
|
||||
|
||||
@defaultResponse
|
||||
default(@body body: ProblemDetails) {}
|
||||
}
|
||||
|
||||
@endpoint({
|
||||
method: 'GET',
|
||||
path: '/version',
|
||||
})
|
||||
class GetVersion {
|
||||
@response({ status: 200 })
|
||||
success(@body body: VersionResponse) {}
|
||||
|
||||
@defaultResponse
|
||||
default(@body body: ProblemDetails) {}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface InitResponse {
|
||||
export interface StatusResponse {
|
||||
installed: boolean;
|
||||
}
|
||||
|
||||
|
||||
27
src/Umbraco.Web.UI.Client/temp-schema-generator/server.ts
Normal file
27
src/Umbraco.Web.UI.Client/temp-schema-generator/server.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { body, defaultResponse, endpoint, response } from '@airtasker/spot';
|
||||
|
||||
import { ProblemDetails, StatusResponse, VersionResponse } from './models';
|
||||
|
||||
@endpoint({
|
||||
method: 'GET',
|
||||
path: '/server/status',
|
||||
})
|
||||
export class GetStatus {
|
||||
@response({ status: 200 })
|
||||
success(@body body: StatusResponse) {}
|
||||
|
||||
@defaultResponse
|
||||
default(@body body: ProblemDetails) {}
|
||||
}
|
||||
|
||||
@endpoint({
|
||||
method: 'GET',
|
||||
path: '/server/version',
|
||||
})
|
||||
export class GetVersion {
|
||||
@response({ status: 200 })
|
||||
success(@body body: VersionResponse) {}
|
||||
|
||||
@defaultResponse
|
||||
default(@body body: ProblemDetails) {}
|
||||
}
|
||||
Reference in New Issue
Block a user