@veloceapps/api 9.0.0-13 → 9.0.0-15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/services/document-templates-api.service.mjs +34 -14
- package/fesm2015/veloceapps-api.mjs +34 -13
- package/fesm2015/veloceapps-api.mjs.map +1 -1
- package/fesm2020/veloceapps-api.mjs +33 -13
- package/fesm2020/veloceapps-api.mjs.map +1 -1
- package/lib/services/document-templates-api.service.d.ts +6 -3
- package/package.json +1 -1
@@ -3,7 +3,7 @@ import { HttpParams, HttpHeaders, HttpErrorResponse, HttpClientModule } from '@a
|
|
3
3
|
import * as i0 from '@angular/core';
|
4
4
|
import { Injectable, NgModule } from '@angular/core';
|
5
5
|
import * as i1 from '@veloceapps/core';
|
6
|
-
import { uiDefinitionFromDTO, ConfigurationContextMode, isLegacyDocumentTemplate, DocxTemplater, StringUtils, Expression, toLatestFlow, isDefined, Operator, isApexError, isCanvasError, ModelTranslatorUtils, ProductModelsContainer, ModelUtils, EntityUtil, RuleGroupTypes, parseJsonSafely, uiDefinitionToDTO, BaseHttpService, XrayService } from '@veloceapps/core';
|
6
|
+
import { uiDefinitionFromDTO, ConfigurationContextMode, isLegacyDocumentTemplate, DocxTemplater, QuoteDraft, StringUtils, Expression, toLatestFlow, isDefined, Operator, isApexError, isCanvasError, ModelTranslatorUtils, ProductModelsContainer, ModelUtils, EntityUtil, RuleGroupTypes, parseJsonSafely, uiDefinitionToDTO, BaseHttpService, XrayService } from '@veloceapps/core';
|
7
7
|
import { noop, throwError, of, zip, forkJoin, map as map$1, from, catchError as catchError$1, switchMap as switchMap$1 } from 'rxjs';
|
8
8
|
import { map, catchError, tap, switchMap, defaultIfEmpty } from 'rxjs/operators';
|
9
9
|
import * as i1$2 from 'primeng/api';
|
@@ -984,23 +984,27 @@ class DocumentTemplatesApiService {
|
|
984
984
|
responseType: 'arraybuffer',
|
985
985
|
});
|
986
986
|
}
|
987
|
-
|
988
|
-
const formData = new FormData();
|
989
|
-
attachments.forEach(attachment => {
|
990
|
-
formData.append('attachments', new Blob([attachment]));
|
991
|
-
});
|
992
|
-
formData.append('orderform', document);
|
987
|
+
generateDocumentV2(body, quoteId, isAsync) {
|
993
988
|
const params = {};
|
994
989
|
if (isAsync) {
|
995
990
|
params['async'] = 'true';
|
996
991
|
}
|
997
|
-
return this.service
|
992
|
+
return this.service
|
993
|
+
.api({
|
998
994
|
method: 'post',
|
999
995
|
url: `/docgen/${quoteId}/generate`,
|
1000
|
-
body
|
996
|
+
body,
|
1001
997
|
params,
|
1002
998
|
responseType: 'arraybuffer',
|
1003
|
-
})
|
999
|
+
})
|
1000
|
+
.pipe(map(pdf => {
|
1001
|
+
const blob = new Blob([pdf]);
|
1002
|
+
const documentName = body.parameters['documentName'] ?? 'Veloce Proposal';
|
1003
|
+
if (!isAsync) {
|
1004
|
+
this.fileDownloadService.processDownload(blob, `${documentName}.${body.documentFormat.toLowerCase()}`);
|
1005
|
+
}
|
1006
|
+
return blob;
|
1007
|
+
}));
|
1004
1008
|
}
|
1005
1009
|
getAttachments(searchRequest) {
|
1006
1010
|
return this.documentAttachmentService.getAttachments(searchRequest);
|
@@ -1030,7 +1034,10 @@ class DocumentTemplatesApiService {
|
|
1030
1034
|
...templateProperties,
|
1031
1035
|
});
|
1032
1036
|
}
|
1033
|
-
|
1037
|
+
/**
|
1038
|
+
* @deprecated
|
1039
|
+
*/
|
1040
|
+
generateDocument(template, object, params = {}) {
|
1034
1041
|
const documentData$ = this.generateDocumentData(template, object, { ...params, shouldPreventDownload: true });
|
1035
1042
|
return zip(this.getTemplateFile(template.id), documentData$, this.resolveAttachments$(template)).pipe(switchMap(([templateFile, data, attachments]) => {
|
1036
1043
|
const document = DocxTemplater.generate(templateFile, data);
|
@@ -1043,9 +1050,22 @@ class DocumentTemplatesApiService {
|
|
1043
1050
|
this.fileDownloadService.processDownload(document, documentName);
|
1044
1051
|
return of(document);
|
1045
1052
|
}
|
1046
|
-
return this.
|
1053
|
+
return this.mergeDocuments(document, attachments).pipe(switchMap(pdf => {
|
1054
|
+
if (params.attachToQuote && QuoteDraft.isQuote(object)) {
|
1055
|
+
const file = new File([pdf], `${documentName}.pdf`);
|
1056
|
+
return this.documentAttachmentService
|
1057
|
+
.createAttachment({
|
1058
|
+
linkedEntityId: object.quoteId,
|
1059
|
+
fileName: documentName,
|
1060
|
+
fileExtension: 'pdf',
|
1061
|
+
tags: this.DOCGEN_TAG,
|
1062
|
+
}, file)
|
1063
|
+
.pipe(map(() => pdf));
|
1064
|
+
}
|
1065
|
+
return of(pdf);
|
1066
|
+
}), map(pdf => {
|
1047
1067
|
const blob = new Blob([pdf]);
|
1048
|
-
if (!
|
1068
|
+
if (!params.shouldPreventDownload) {
|
1049
1069
|
this.fileDownloadService.processDownload(blob, `${documentName}.pdf`);
|
1050
1070
|
}
|
1051
1071
|
return blob;
|