new server models

This commit is contained in:
Mads Rasmussen
2024-04-09 08:40:10 +02:00
parent 368bc3eace
commit 4cfcc390e1
5 changed files with 182 additions and 16 deletions

View File

@@ -232,21 +232,13 @@ export const getResponseBody = async (response: Response): Promise<any> => {
try {
const contentType = response.headers.get('Content-Type');
if (contentType) {
const binaryTypes = ['application/octet-stream', 'application/pdf', 'application/zip'];
const isBinary = binaryTypes.some(type => contentType.toLowerCase().startsWith(type));
if (isBinary) {
return await response.blob();
}
const jsonTypes = ['application/json', 'application/problem+json']
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
if (isJSON) {
return await response.json();
}
return await response.text();
const jsonTypes = ['application/json', 'application/problem+json']
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
if (isJSON) {
return await response.json();
} else {
return await response.text();
}
}
} catch (error) {
console.error(error);

View File

@@ -195,6 +195,7 @@ export type { ModelsBuilderResponseModel } from './models/ModelsBuilderResponseM
export { ModelsModeModel } from './models/ModelsModeModel';
export type { MoveDataTypeRequestModel } from './models/MoveDataTypeRequestModel';
export type { MoveDictionaryRequestModel } from './models/MoveDictionaryRequestModel';
export type { MoveDocumentBlueprintRequestModel } from './models/MoveDocumentBlueprintRequestModel';
export type { MoveDocumentRequestModel } from './models/MoveDocumentRequestModel';
export type { MoveDocumentTypeRequestModel } from './models/MoveDocumentTypeRequestModel';
export type { MoveMediaRequestModel } from './models/MoveMediaRequestModel';

View File

@@ -11,6 +11,7 @@ export type DocumentBlueprintTreeItemResponseModel = {
id: string;
parent?: ReferenceByIdModel | null;
name: string;
documentType: DocumentTypeReferenceResponseModel;
isFolder: boolean;
documentType?: DocumentTypeReferenceResponseModel | null;
};

View File

@@ -0,0 +1,11 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ReferenceByIdModel } from './ReferenceByIdModel';
export type MoveDocumentBlueprintRequestModel = {
target?: ReferenceByIdModel | null;
};

View File

@@ -4,10 +4,14 @@
/* eslint-disable */
import type { CreateDocumentBlueprintFromDocumentRequestModel } from '../models/CreateDocumentBlueprintFromDocumentRequestModel';
import type { CreateDocumentBlueprintRequestModel } from '../models/CreateDocumentBlueprintRequestModel';
import type { CreateFolderRequestModel } from '../models/CreateFolderRequestModel';
import type { DocumentBlueprintItemResponseModel } from '../models/DocumentBlueprintItemResponseModel';
import type { DocumentBlueprintResponseModel } from '../models/DocumentBlueprintResponseModel';
import type { FolderResponseModel } from '../models/FolderResponseModel';
import type { MoveDocumentBlueprintRequestModel } from '../models/MoveDocumentBlueprintRequestModel';
import type { PagedDocumentBlueprintTreeItemResponseModel } from '../models/PagedDocumentBlueprintTreeItemResponseModel';
import type { UpdateDocumentBlueprintRequestModel } from '../models/UpdateDocumentBlueprintRequestModel';
import type { UpdateFolderResponseModel } from '../models/UpdateFolderResponseModel';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
@@ -112,6 +116,130 @@ export class DocumentBlueprintResource {
});
}
/**
* @returns string Success
* @throws ApiError
*/
public static putDocumentBlueprintByIdMove({
id,
requestBody,
}: {
id: string,
requestBody?: MoveDocumentBlueprintRequestModel,
}): CancelablePromise<string> {
return __request(OpenAPI, {
method: 'PUT',
url: '/umbraco/management/api/v1/document-blueprint/{id}/move',
path: {
'id': id,
},
body: requestBody,
mediaType: 'application/json',
responseHeader: 'Umb-Notifications',
errors: {
401: `The resource is protected and requires an authentication token`,
404: `Not Found`,
},
});
}
/**
* @returns string Created
* @throws ApiError
*/
public static postDocumentBlueprintFolder({
requestBody,
}: {
requestBody?: CreateFolderRequestModel,
}): CancelablePromise<string> {
return __request(OpenAPI, {
method: 'POST',
url: '/umbraco/management/api/v1/document-blueprint/folder',
body: requestBody,
mediaType: 'application/json',
responseHeader: 'Umb-Generated-Resource',
errors: {
400: `Bad Request`,
401: `The resource is protected and requires an authentication token`,
404: `Not Found`,
},
});
}
/**
* @returns any Success
* @throws ApiError
*/
public static getDocumentBlueprintFolderById({
id,
}: {
id: string,
}): CancelablePromise<FolderResponseModel> {
return __request(OpenAPI, {
method: 'GET',
url: '/umbraco/management/api/v1/document-blueprint/folder/{id}',
path: {
'id': id,
},
errors: {
401: `The resource is protected and requires an authentication token`,
404: `Not Found`,
},
});
}
/**
* @returns string Success
* @throws ApiError
*/
public static deleteDocumentBlueprintFolderById({
id,
}: {
id: string,
}): CancelablePromise<string> {
return __request(OpenAPI, {
method: 'DELETE',
url: '/umbraco/management/api/v1/document-blueprint/folder/{id}',
path: {
'id': id,
},
responseHeader: 'Umb-Notifications',
errors: {
400: `Bad Request`,
401: `The resource is protected and requires an authentication token`,
404: `Not Found`,
},
});
}
/**
* @returns string Success
* @throws ApiError
*/
public static putDocumentBlueprintFolderById({
id,
requestBody,
}: {
id: string,
requestBody?: UpdateFolderResponseModel,
}): CancelablePromise<string> {
return __request(OpenAPI, {
method: 'PUT',
url: '/umbraco/management/api/v1/document-blueprint/folder/{id}',
path: {
'id': id,
},
body: requestBody,
mediaType: 'application/json',
responseHeader: 'Umb-Notifications',
errors: {
400: `Bad Request`,
401: `The resource is protected and requires an authentication token`,
404: `Not Found`,
},
});
}
/**
* @returns string Created
* @throws ApiError
@@ -156,6 +284,36 @@ export class DocumentBlueprintResource {
});
}
/**
* @returns any Success
* @throws ApiError
*/
public static getTreeDocumentBlueprintChildren({
parentId,
skip,
take = 100,
foldersOnly = false,
}: {
parentId?: string,
skip?: number,
take?: number,
foldersOnly?: boolean,
}): CancelablePromise<PagedDocumentBlueprintTreeItemResponseModel> {
return __request(OpenAPI, {
method: 'GET',
url: '/umbraco/management/api/v1/tree/document-blueprint/children',
query: {
'parentId': parentId,
'skip': skip,
'take': take,
'foldersOnly': foldersOnly,
},
errors: {
401: `The resource is protected and requires an authentication token`,
},
});
}
/**
* @returns any Success
* @throws ApiError
@@ -163,9 +321,11 @@ export class DocumentBlueprintResource {
public static getTreeDocumentBlueprintRoot({
skip,
take = 100,
foldersOnly = false,
}: {
skip?: number,
take?: number,
foldersOnly?: boolean,
}): CancelablePromise<PagedDocumentBlueprintTreeItemResponseModel> {
return __request(OpenAPI, {
method: 'GET',
@@ -173,6 +333,7 @@ export class DocumentBlueprintResource {
query: {
'skip': skip,
'take': take,
'foldersOnly': foldersOnly,
},
errors: {
401: `The resource is protected and requires an authentication token`,