revamp installer models

This commit is contained in:
Jacob Overgaard
2022-06-27 11:07:17 +02:00
parent 39b3e0a319
commit 99bd3175cb
7 changed files with 134 additions and 102 deletions

View File

@@ -3,24 +3,31 @@ info:
title: umbraco-backoffice-api
version: 1.0.0
paths:
/install:
/install/settings:
get:
operationId: GetInstall
operationId: GetInstallSettings
responses:
'200':
description: 200 response
content:
application/json:
schema:
$ref: '#/components/schemas/UmbracoInstaller'
$ref: '#/components/schemas/InstallSettingsResponse'
default:
description: default response
content:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetails'
/install/setup:
post:
operationId: PostInstall
operationId: PostInstallSetup
parameters: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UmbracoPerformInstallRequest'
$ref: '#/components/schemas/InstallSetupRequest'
required: true
responses:
'201':
@@ -31,7 +38,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetails'
/install/database/validate:
/install/validateDatabase:
post:
operationId: PostInstallValidateDatabase
parameters: []
@@ -39,7 +46,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/UmbracoPerformInstallDatabaseConfiguration'
$ref: '#/components/schemas/InstallValidateDatabaseRequest'
required: true
responses:
'201':
@@ -163,7 +170,7 @@ components:
required:
- level
- description
UmbracoInstallerUserModel:
InstallUserModel:
type: object
properties:
minCharLength:
@@ -180,7 +187,7 @@ components:
- minCharLength
- minNonAlphaNumericLength
- consentLevels
UmbracoInstallerDatabaseModel:
InstallDatabaseModel:
type: object
properties:
id:
@@ -220,19 +227,38 @@ components:
- requiresCredentials
- supportsIntegratedAuthentication
- requiresConnectionTest
UmbracoInstaller:
InstallSettingsResponse:
type: object
properties:
user:
$ref: '#/components/schemas/UmbracoInstallerUserModel'
$ref: '#/components/schemas/InstallUserModel'
databases:
type: array
items:
$ref: '#/components/schemas/UmbracoInstallerDatabaseModel'
$ref: '#/components/schemas/InstallDatabaseModel'
required:
- user
- databases
UmbracoPerformInstallDatabaseConfiguration:
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
InstallSetupDatabaseConfiguration:
type: object
properties:
server:
@@ -256,7 +282,7 @@ components:
connectionString:
type: string
nullable: true
UmbracoPerformInstallRequest:
InstallSetupRequest:
type: object
properties:
name:
@@ -270,7 +296,7 @@ components:
telemetryLevel:
$ref: '#/components/schemas/ConsentLevel'
database:
$ref: '#/components/schemas/UmbracoPerformInstallDatabaseConfiguration'
$ref: '#/components/schemas/InstallSetupDatabaseConfiguration'
required:
- name
- email
@@ -278,25 +304,13 @@ components:
- subscribeToNewsletter
- telemetryLevel
- database
ProblemDetails:
InstallValidateDatabaseRequest:
type: object
properties:
type:
type: string
status:
type: number
format: float
title:
type: string
detail:
type: string
instance:
type: string
errors:
type: object
database:
$ref: '#/components/schemas/InstallSetupDatabaseConfiguration'
required:
- type
- status
- database
StatusResponse:
type: object
properties:

View File

@@ -4,11 +4,13 @@
*/
export interface paths {
"/install": {
get: operations["GetInstall"];
post: operations["PostInstall"];
"/install/settings": {
get: operations["GetInstallSettings"];
};
"/install/database/validate": {
"/install/setup": {
post: operations["PostInstallSetup"];
};
"/install/validateDatabase": {
post: operations["PostInstallValidateDatabase"];
};
"/server/status": {
@@ -39,14 +41,14 @@ export interface components {
level: components["schemas"]["ConsentLevel"];
description: string;
};
UmbracoInstallerUserModel: {
InstallUserModel: {
/** Format: float */
minCharLength: number;
/** Format: float */
minNonAlphaNumericLength: number;
consentLevels: components["schemas"]["TelemetryModel"][];
};
UmbracoInstallerDatabaseModel: {
InstallDatabaseModel: {
id: string;
/** Format: float */
sortOrder: number;
@@ -60,26 +62,9 @@ export interface components {
supportsIntegratedAuthentication: boolean;
requiresConnectionTest: boolean;
};
UmbracoInstaller: {
user: components["schemas"]["UmbracoInstallerUserModel"];
databases: components["schemas"]["UmbracoInstallerDatabaseModel"][];
};
UmbracoPerformInstallDatabaseConfiguration: {
server?: string | null;
password?: string | null;
username?: string | null;
databaseName?: string | null;
databaseType?: string | null;
useIntegratedAuthentication?: boolean | null;
connectionString?: string | null;
};
UmbracoPerformInstallRequest: {
name: string;
email: string;
password: string;
subscribeToNewsletter: boolean;
telemetryLevel: components["schemas"]["ConsentLevel"];
database: components["schemas"]["UmbracoPerformInstallDatabaseConfiguration"];
InstallSettingsResponse: {
user: components["schemas"]["InstallUserModel"];
databases: components["schemas"]["InstallDatabaseModel"][];
};
ProblemDetails: {
type: string;
@@ -90,6 +75,26 @@ export interface components {
instance?: string;
errors?: { [key: string]: unknown };
};
InstallSetupDatabaseConfiguration: {
server?: string | null;
password?: string | null;
username?: string | null;
databaseName?: string | null;
databaseType?: string | null;
useIntegratedAuthentication?: boolean | null;
connectionString?: string | null;
};
InstallSetupRequest: {
name: string;
email: string;
password: string;
subscribeToNewsletter: boolean;
telemetryLevel: components["schemas"]["ConsentLevel"];
database: components["schemas"]["InstallSetupDatabaseConfiguration"];
};
InstallValidateDatabaseRequest: {
database: components["schemas"]["InstallSetupDatabaseConfiguration"];
};
StatusResponse: {
installed: boolean;
};
@@ -112,17 +117,23 @@ export interface components {
}
export interface operations {
GetInstall: {
GetInstallSettings: {
responses: {
/** 200 response */
200: {
content: {
"application/json": components["schemas"]["UmbracoInstaller"];
"application/json": components["schemas"]["InstallSettingsResponse"];
};
};
/** default response */
default: {
content: {
"application/json": components["schemas"]["ProblemDetails"];
};
};
};
};
PostInstall: {
PostInstallSetup: {
parameters: {};
responses: {
/** 201 response */
@@ -136,7 +147,7 @@ export interface operations {
};
requestBody: {
content: {
"application/json": components["schemas"]["UmbracoPerformInstallRequest"];
"application/json": components["schemas"]["InstallSetupRequest"];
};
};
};
@@ -154,7 +165,7 @@ export interface operations {
};
requestBody: {
content: {
"application/json": components["schemas"]["UmbracoPerformInstallDatabaseConfiguration"];
"application/json": components["schemas"]["InstallValidateDatabaseRequest"];
};
};
};

View File

@@ -14,5 +14,6 @@ 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();
export const getUserSections = fetcher.path('/user/sections').method('get').create();
export const getInstall = fetcher.path('/install').method('get').create();
export const postInstall = fetcher.path('/install').method('post').create();
export const getInstallSettings = fetcher.path('/install/settings').method('get').create();
export const postInstallValidateDatabase = fetcher.path('/install/validateDatabase').method('post').create();
export const postInstallSetup = fetcher.path('/install/setup').method('post').create();

View File

@@ -1,19 +1,17 @@
import { components } from '../../../schemas/generated-schema';
export type PostInstallRequest = components['schemas']['UmbracoPerformInstallRequest'];
export type PostInstallRequest = components['schemas']['InstallSetupRequest'];
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'];
export type UmbracoInstaller = components['schemas']['InstallSettingsResponse'];
// Models
export type UmbracoInstallerDatabaseModel = components['schemas']['UmbracoInstallerDatabaseModel'];
export type UmbracoInstallerUserModel = components['schemas']['UmbracoInstallerUserModel'];
export type UmbracoPerformInstallDatabaseConfiguration = components['schemas']['InstallSetupDatabaseConfiguration'];
export type UmbracoInstallerDatabaseModel = components['schemas']['InstallDatabaseModel'];
export type UmbracoInstallerUserModel = components['schemas']['InstallUserModel'];
export type TelemetryModel = components['schemas']['TelemetryModel'];
// eslint-disable-next-line @typescript-eslint/no-explicit-any

View File

@@ -1,7 +1,8 @@
import { getInstall, postInstall } from '../core/api/fetcher';
import { PostInstallRequest, UmbracoInstaller } from '../core/models';
import { BehaviorSubject, Observable, ReplaySubject, Subject } from 'rxjs';
import { getInstallSettings, postInstallSetup } from '../core/api/fetcher';
import { PostInstallRequest, UmbracoInstaller } from '../core/models';
export class UmbInstallerContext {
private _data: BehaviorSubject<PostInstallRequest> = new BehaviorSubject<PostInstallRequest>({
name: '',
@@ -30,14 +31,14 @@ export class UmbInstallerContext {
public requestInstall() {
return new Promise((resolve, reject) => {
postInstall(this._data.getValue()).then(resolve, ({ data }) => {
postInstallSetup(this._data.getValue()).then(resolve, ({ data }) => {
reject(data);
});
});
}
private loadIntallerSettings() {
getInstall({}).then(({ data }) => {
getInstallSettings({}).then(({ data }) => {
this._settings.next(data);
});
}

View File

@@ -1,9 +1,9 @@
import { rest } from 'msw';
import { ProblemDetails, UmbracoInstaller, UmbracoPerformInstallRequest } from '../../core/models';
import { PostInstallRequest, ProblemDetails, UmbracoInstaller } from '../../core/models';
export const handlers = [
rest.get('/umbraco/backoffice/install', (_req, res, ctx) => {
rest.get('/umbraco/backoffice/install/settings', (_req, res, ctx) => {
return res(
// Respond with a 200 status code
ctx.status(200),
@@ -72,7 +72,7 @@ export const handlers = [
);
}),
rest.post<UmbracoPerformInstallRequest>('/umbraco/backoffice/install', async (req, res, ctx) => {
rest.post<PostInstallRequest>('/umbraco/backoffice/install/setup', async (req, res, ctx) => {
await new Promise((resolve) => setTimeout(resolve, (Math.random() + 1) * 1000)); // simulate a delay of 1-2 seconds
if (req.body.database.databaseName === 'fail') {

View File

@@ -1,23 +1,26 @@
import { body, endpoint, request, response } from '@airtasker/spot';
import { body, defaultResponse, endpoint, request, response } from '@airtasker/spot';
import { ProblemDetails } from './models';
@endpoint({
method: 'GET',
path: '/install',
path: '/install/settings',
})
export class GetInstall {
export class GetInstallSettings {
@response({ status: 200 })
success(@body body: UmbracoInstaller) {}
success(@body body: InstallSettingsResponse) {}
@defaultResponse
default(@body body: ProblemDetails) {}
}
@endpoint({
method: 'POST',
path: '/install',
path: '/install/setup',
})
export class PostInstall {
export class PostInstallSetup {
@request
request(@body body: UmbracoPerformInstallRequest) {}
request(@body body: InstallSetupRequest) {}
@response({ status: 201 })
success() {}
@@ -28,11 +31,11 @@ export class PostInstall {
@endpoint({
method: 'POST',
path: '/install/database/validate',
path: '/install/validateDatabase',
})
export class PostInstallValidateDatabase {
@request
request(@body body: UmbracoPerformInstallDatabaseConfiguration) {}
request(@body body: InstallValidateDatabaseRequest) {}
@response({ status: 201 })
success() {}
@@ -41,16 +44,31 @@ export class PostInstallValidateDatabase {
badRequest(@body body: ProblemDetails) {}
}
export interface UmbracoPerformInstallRequest {
export interface InstallSetupRequest {
name: string;
email: string;
password: string;
subscribeToNewsletter: boolean;
telemetryLevel: ConsentLevel;
database: UmbracoPerformInstallDatabaseConfiguration;
database: InstallSetupDatabaseConfiguration;
}
export interface UmbracoPerformInstallDatabaseConfiguration {
export interface InstallValidateDatabaseRequest {
database: InstallSetupDatabaseConfiguration;
}
export interface InstallSettingsResponse {
user: InstallUserModel;
databases: InstallDatabaseModel[];
}
export interface InstallUserModel {
minCharLength: number;
minNonAlphaNumericLength: number;
consentLevels: TelemetryModel[];
}
export interface InstallSetupDatabaseConfiguration {
server?: string | null;
password?: string | null;
username?: string | null;
@@ -60,23 +78,12 @@ export interface UmbracoPerformInstallDatabaseConfiguration {
connectionString?: string | null;
}
export interface UmbracoInstaller {
user: UmbracoInstallerUserModel;
databases: UmbracoInstallerDatabaseModel[];
}
export interface UmbracoInstallerUserModel {
minCharLength: number;
minNonAlphaNumericLength: number;
consentLevels: TelemetryModel[];
}
export interface TelemetryModel {
level: ConsentLevel;
description: string;
}
export interface UmbracoInstallerDatabaseModel {
export interface InstallDatabaseModel {
id: string;
sortOrder: number;
displayName: string;