remove hacks because server has been updated

This commit is contained in:
Mads Rasmussen
2023-09-14 12:17:05 +02:00
parent d4c527e13f
commit a62cc46176

View File

@@ -86,40 +86,21 @@ export class UmbDocumentServerDataSource
* @return {*}
* @memberof UmbDocumentServerDataSource
*/
async insert(document: CreateDocumentRequestModel & { id: string }) {
async insert(document: CreateDocumentRequestModel) {
if (!document.id) throw new Error('Id is missing');
// TODO: Hack to remove some props that ruins the document-type post end-point.
const unFroozenDocument = { ...document };
(unFroozenDocument as any).id = undefined;
(unFroozenDocument.variants as any) =
unFroozenDocument.variants?.map((variant) => {
return { ...variant };
}) ?? [];
return tryExecuteAndNotify(this.#host, DocumentResource.postDocument({ requestBody: unFroozenDocument }));
return tryExecuteAndNotify(this.#host, DocumentResource.postDocument({ requestBody: document }));
}
/**
* Updates a Document on the server
* @param {Document} Document
* @param {string} id
* @param {UpdateDocumentRequestModel} document
* @return {*}
* @memberof UmbDocumentServerDataSource
*/
async update(id: string, document: UpdateDocumentRequestModel) {
if (!id) throw new Error('Id is missing');
// TODO: Hack to remove some props that ruins the document-type post end-point.
const unFroozenDocument = { ...document };
(unFroozenDocument as any).id = undefined;
(unFroozenDocument.variants as any) =
unFroozenDocument.variants?.map((variant) => {
return { ...variant };
}) ?? [];
return tryExecuteAndNotify(this.#host, DocumentResource.putDocumentById({ id, requestBody: unFroozenDocument }));
return tryExecuteAndNotify(this.#host, DocumentResource.putDocumentById({ id, requestBody: document }));
}
/**