From c5596d5bdbcdcf681b0ef8ea5ca8720d48f36a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 7 Jul 2023 10:42:01 +0200 Subject: [PATCH] clean up --- .../src/services/DocumentResource.ts | 950 +++++++++--------- .../sources/document.server.data.ts | 5 +- 2 files changed, 465 insertions(+), 490 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/external/backend-api/src/services/DocumentResource.ts b/src/Umbraco.Web.UI.Client/src/external/backend-api/src/services/DocumentResource.ts index 8f5acecf35..bc2a250e54 100644 --- a/src/Umbraco.Web.UI.Client/src/external/backend-api/src/services/DocumentResource.ts +++ b/src/Umbraco.Web.UI.Client/src/external/backend-api/src/services/DocumentResource.ts @@ -20,512 +20,486 @@ import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class DocumentResource { + /** + * @returns string Created + * @throws ApiError + */ + public static postDocument({ requestBody }: { requestBody?: CreateDocumentRequestModel }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/umbraco/management/api/v1/document', + body: requestBody, + mediaType: 'application/json', + responseHeader: 'Location', + errors: { + 400: `Bad Request`, + 404: `Not Found`, + }, + }); + } - /** - * @returns string Created - * @throws ApiError - */ - public static postDocument({ - requestBody, - }: { - requestBody?: CreateDocumentRequestModel, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/umbraco/management/api/v1/document', - body: requestBody, - mediaType: 'application/json', - responseHeader: 'Location', - errors: { - 400: `Bad Request`, - 404: `Not Found`, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static getDocumentById({ id }: { id: string }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/document/{id}', + path: { + id: id, + }, + errors: { + 404: `Not Found`, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static getDocumentById({ - id, - }: { - id: string, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/document/{id}', - path: { - 'id': id, - }, - errors: { - 404: `Not Found`, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static deleteDocumentById({ id }: { id: string }): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/umbraco/management/api/v1/document/{id}', + path: { + id: id, + }, + errors: { + 400: `Bad Request`, + 404: `Not Found`, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static deleteDocumentById({ - id, - }: { - id: string, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/umbraco/management/api/v1/document/{id}', - path: { - 'id': id, - }, - errors: { - 400: `Bad Request`, - 404: `Not Found`, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static putDocumentById({ + id, + requestBody, + }: { + id: string; + requestBody?: UpdateDocumentRequestModel; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/umbraco/management/api/v1/document/{id}', + path: { + id: id, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `Bad Request`, + 404: `Not Found`, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static putDocumentById({ - id, - requestBody, - }: { - id: string, - requestBody?: UpdateDocumentRequestModel, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/umbraco/management/api/v1/document/{id}', - path: { - 'id': id, - }, - body: requestBody, - mediaType: 'application/json', - errors: { - 400: `Bad Request`, - 404: `Not Found`, - }, - }); - } + /** + * @returns PagedDocumentTypeResponseModel Success + * @throws ApiError + */ + public static getDocumentByIdAllowedDocumentTypes({ + id, + skip, + take = 100, + }: { + id: string; + skip?: number; + take?: number; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/document/{id}/allowed-document-types', + path: { + id: id, + }, + query: { + skip: skip, + take: take, + }, + errors: { + 404: `Not Found`, + }, + }); + } - /** - * @returns PagedDocumentTypeResponseModel Success - * @throws ApiError - */ - public static getDocumentByIdAllowedDocumentTypes({ - id, - skip, - take = 100, - }: { - id: string, - skip?: number, - take?: number, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/document/{id}/allowed-document-types', - path: { - 'id': id, - }, - query: { - 'skip': skip, - 'take': take, - }, - errors: { - 404: `Not Found`, - }, - }); - } + /** + * @returns string Created + * @throws ApiError + */ + public static postDocumentByIdCopy({ + id, + requestBody, + }: { + id: string; + requestBody?: CopyDocumentRequestModel; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/umbraco/management/api/v1/document/{id}/copy', + path: { + id: id, + }, + body: requestBody, + mediaType: 'application/json', + responseHeader: 'Location', + errors: { + 400: `Bad Request`, + 404: `Not Found`, + }, + }); + } - /** - * @returns string Created - * @throws ApiError - */ - public static postDocumentByIdCopy({ - id, - requestBody, - }: { - id: string, - requestBody?: CopyDocumentRequestModel, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/umbraco/management/api/v1/document/{id}/copy', - path: { - 'id': id, - }, - body: requestBody, - mediaType: 'application/json', - responseHeader: 'Location', - errors: { - 400: `Bad Request`, - 404: `Not Found`, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static getDocumentByIdDomains({ id }: { id: string }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/document/{id}/domains', + path: { + id: id, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static getDocumentByIdDomains({ - id, - }: { - id: string, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/document/{id}/domains', - path: { - 'id': id, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static putDocumentByIdDomains({ + id, + requestBody, + }: { + id: string; + requestBody?: UpdateDomainsRequestModel; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/umbraco/management/api/v1/document/{id}/domains', + path: { + id: id, + }, + body: requestBody, + mediaType: 'application/json', + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static putDocumentByIdDomains({ - id, - requestBody, - }: { - id: string, - requestBody?: UpdateDomainsRequestModel, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/umbraco/management/api/v1/document/{id}/domains', - path: { - 'id': id, - }, - body: requestBody, - mediaType: 'application/json', - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static putDocumentByIdMove({ + id, + requestBody, + }: { + id: string; + requestBody?: MoveDocumentRequestModel; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/umbraco/management/api/v1/document/{id}/move', + path: { + id: id, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `Bad Request`, + 404: `Not Found`, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static putDocumentByIdMove({ - id, - requestBody, - }: { - id: string, - requestBody?: MoveDocumentRequestModel, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/umbraco/management/api/v1/document/{id}/move', - path: { - 'id': id, - }, - body: requestBody, - mediaType: 'application/json', - errors: { - 400: `Bad Request`, - 404: `Not Found`, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static getDocumentByIdNotifications({ + id, + }: { + id: string; + }): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/document/{id}/notifications', + path: { + id: id, + }, + errors: { + 404: `Not Found`, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static getDocumentByIdNotifications({ - id, - }: { - id: string, - }): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/document/{id}/notifications', - path: { - 'id': id, - }, - errors: { - 404: `Not Found`, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static putDocumentByIdNotifications({ + id, + requestBody, + }: { + id: string; + requestBody?: UpdateDocumentNotificationsRequestModel; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/umbraco/management/api/v1/document/{id}/notifications', + path: { + id: id, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 404: `Not Found`, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static putDocumentByIdNotifications({ - id, - requestBody, - }: { - id: string, - requestBody?: UpdateDocumentNotificationsRequestModel, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/umbraco/management/api/v1/document/{id}/notifications', - path: { - 'id': id, - }, - body: requestBody, - mediaType: 'application/json', - errors: { - 404: `Not Found`, - }, - }); - } + /** + * @returns string Created + * @throws ApiError + */ + public static postDocumentByIdPublicAccess({ + id, + requestBody, + }: { + id: string; + requestBody?: PublicAccessRequestModel; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/umbraco/management/api/v1/document/{id}/public-access', + path: { + id: id, + }, + body: requestBody, + mediaType: 'application/json', + responseHeader: 'Location', + errors: { + 400: `Bad Request`, + 404: `Not Found`, + }, + }); + } - /** - * @returns string Created - * @throws ApiError - */ - public static postDocumentByIdPublicAccess({ - id, - requestBody, - }: { - id: string, - requestBody?: PublicAccessRequestModel, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/umbraco/management/api/v1/document/{id}/public-access', - path: { - 'id': id, - }, - body: requestBody, - mediaType: 'application/json', - responseHeader: 'Location', - errors: { - 400: `Bad Request`, - 404: `Not Found`, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static deleteDocumentByIdPublicAccess({ id }: { id: string }): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/umbraco/management/api/v1/document/{id}/public-access', + path: { + id: id, + }, + errors: { + 404: `Not Found`, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static deleteDocumentByIdPublicAccess({ - id, - }: { - id: string, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/umbraco/management/api/v1/document/{id}/public-access', - path: { - 'id': id, - }, - errors: { - 404: `Not Found`, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static getDocumentByIdPublicAccess({ id }: { id: string }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/document/{id}/public-access', + path: { + id: id, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static getDocumentByIdPublicAccess({ - id, - }: { - id: string, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/document/{id}/public-access', - path: { - 'id': id, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static putDocumentByIdPublicAccess({ + id, + requestBody, + }: { + id: string; + requestBody?: PublicAccessRequestModel; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/umbraco/management/api/v1/document/{id}/public-access', + path: { + id: id, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `Bad Request`, + 404: `Not Found`, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static putDocumentByIdPublicAccess({ - id, - requestBody, - }: { - id: string, - requestBody?: PublicAccessRequestModel, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/umbraco/management/api/v1/document/{id}/public-access', - path: { - 'id': id, - }, - body: requestBody, - mediaType: 'application/json', - errors: { - 400: `Bad Request`, - 404: `Not Found`, - }, - }); - } + /** + * @returns any Success + * @throws ApiError + */ + public static getDocumentItem({ + id, + dataTypeId, + culture, + }: { + id?: Array; + dataTypeId?: string; + culture?: string; + }): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/document/item', + query: { + id: id, + dataTypeId: dataTypeId, + culture: culture, + }, + }); + } - /** - * @returns any Success - * @throws ApiError - */ - public static getDocumentItem({ - id, - dataTypeId, - culture, - }: { - id?: Array, - dataTypeId?: string, - culture?: string, - }): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/document/item', - query: { - 'id': id, - 'dataTypeId': dataTypeId, - 'culture': culture, - }, - }); - } + /** + * @returns PagedDocumentTypeResponseModel Success + * @throws ApiError + */ + public static getDocumentRootAllowedDocumentTypes({ + skip, + take = 100, + }: { + skip?: number; + take?: number; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/document/root/allowed-document-types', + query: { + skip: skip, + take: take, + }, + errors: { + 404: `Not Found`, + }, + }); + } - /** - * @returns PagedDocumentTypeResponseModel Success - * @throws ApiError - */ - public static getDocumentRootAllowedDocumentTypes({ - skip, - take = 100, - }: { - skip?: number, - take?: number, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/document/root/allowed-document-types', - query: { - 'skip': skip, - 'take': take, - }, - errors: { - 404: `Not Found`, - }, - }); - } + /** + * @returns PagedRecycleBinItemResponseModel Success + * @throws ApiError + */ + public static getRecycleBinDocumentChildren({ + parentId, + skip, + take = 100, + }: { + parentId?: string; + skip?: number; + take?: number; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/recycle-bin/document/children', + query: { + parentId: parentId, + skip: skip, + take: take, + }, + errors: { + 401: `Unauthorized`, + }, + }); + } - /** - * @returns PagedRecycleBinItemResponseModel Success - * @throws ApiError - */ - public static getRecycleBinDocumentChildren({ - parentId, - skip, - take = 100, - }: { - parentId?: string, - skip?: number, - take?: number, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/recycle-bin/document/children', - query: { - 'parentId': parentId, - 'skip': skip, - 'take': take, - }, - errors: { - 401: `Unauthorized`, - }, - }); - } + /** + * @returns PagedRecycleBinItemResponseModel Success + * @throws ApiError + */ + public static getRecycleBinDocumentRoot({ + skip, + take = 100, + }: { + skip?: number; + take?: number; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/recycle-bin/document/root', + query: { + skip: skip, + take: take, + }, + errors: { + 401: `Unauthorized`, + }, + }); + } - /** - * @returns PagedRecycleBinItemResponseModel Success - * @throws ApiError - */ - public static getRecycleBinDocumentRoot({ - skip, - take = 100, - }: { - skip?: number, - take?: number, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/recycle-bin/document/root', - query: { - 'skip': skip, - 'take': take, - }, - errors: { - 401: `Unauthorized`, - }, - }); - } - - /** - * @returns PagedDocumentTreeItemResponseModel Success - * @throws ApiError - */ - public static getTreeDocumentChildren({ - parentId, - skip, - take = 100, - dataTypeId, - culture, - }: { - parentId?: string, - skip?: number, - take?: number, - dataTypeId?: string, - culture?: string, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/tree/document/children', - query: { - 'parentId': parentId, - 'skip': skip, - 'take': take, - 'dataTypeId': dataTypeId, - 'culture': culture, - }, - }); - } - - /** - * @returns PagedDocumentTreeItemResponseModel Success - * @throws ApiError - */ - public static getTreeDocumentRoot({ - skip, - take = 100, - dataTypeId, - culture, - }: { - skip?: number, - take?: number, - dataTypeId?: string, - culture?: string, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/umbraco/management/api/v1/tree/document/root', - query: { - 'skip': skip, - 'take': take, - 'dataTypeId': dataTypeId, - 'culture': culture, - }, - }); - } + /** + * @returns PagedDocumentTreeItemResponseModel Success + * @throws ApiError + */ + public static getTreeDocumentChildren({ + parentId, + skip, + take = 100, + dataTypeId, + culture, + }: { + parentId?: string; + skip?: number; + take?: number; + dataTypeId?: string; + culture?: string; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/tree/document/children', + query: { + parentId: parentId, + skip: skip, + take: take, + dataTypeId: dataTypeId, + culture: culture, + }, + }); + } + /** + * @returns PagedDocumentTreeItemResponseModel Success + * @throws ApiError + */ + public static getTreeDocumentRoot({ + skip, + take = 100, + dataTypeId, + culture, + }: { + skip?: number; + take?: number; + dataTypeId?: string; + culture?: string; + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/tree/document/root', + query: { + skip: skip, + take: take, + dataTypeId: dataTypeId, + culture: culture, + }, + }); + } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/sources/document.server.data.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/sources/document.server.data.ts index f41d6ac3ab..8eeefe8b9c 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/sources/document.server.data.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/sources/document.server.data.ts @@ -178,6 +178,7 @@ export class UmbDocumentServerDataSource async getAllowedDocumentTypesOf(id: string) { if (!id) throw new Error('Id is missing'); + // TODO: Notice, here we need to implement pagination. return tryExecuteAndNotify(this.#host, DocumentResource.getDocumentByIdAllowedDocumentTypes({ id })); } @@ -189,7 +190,7 @@ export class UmbDocumentServerDataSource */ async getAllowedDocumentTypesAtRoot() { console.log('source requestAllowedDocumentTypesAtRoot'); - // Notice, here we need to implement pagination. - return tryExecuteAndNotify(this.#host, DocumentResource.getDocumentRootAllowedDocumentTypes({ take: 4 })); + // TODO: Notice, here we need to implement pagination. + return tryExecuteAndNotify(this.#host, DocumentResource.getDocumentRootAllowedDocumentTypes({})); } }