@veloceapps/api 9.0.0-10 → 9.0.0-11
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 +27 -19
- package/fesm2015/veloceapps-api.mjs +26 -18
- package/fesm2015/veloceapps-api.mjs.map +1 -1
- package/fesm2020/veloceapps-api.mjs +26 -18
- package/fesm2020/veloceapps-api.mjs.map +1 -1
- package/lib/services/document-templates-api.service.d.ts +6 -2
- 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,
|
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';
|
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';
|
@@ -868,8 +868,8 @@ class DocumentTemplatesApiService {
|
|
868
868
|
this.fileDownloadService = fileDownloadService;
|
869
869
|
this.documentAttachmentService = documentAttachmentService;
|
870
870
|
this.http = http;
|
871
|
-
this.DOCGEN_TAG = 'docgen';
|
872
871
|
this.SERVICE_URL = '/templates';
|
872
|
+
this.DOCGEN_TAG = 'docgen';
|
873
873
|
this.DOC_GEN_URL_FALLBACK = `${window.VELO_API}/docgen`;
|
874
874
|
this.mapSfQueryResult = (limit) => map((records) => {
|
875
875
|
if (!records.length) {
|
@@ -971,6 +971,9 @@ class DocumentTemplatesApiService {
|
|
971
971
|
this.fileDownloadService.processDownload(response);
|
972
972
|
}), map(response => response.body || response));
|
973
973
|
}
|
974
|
+
/**
|
975
|
+
* @deprecated
|
976
|
+
*/
|
974
977
|
mergeDocuments(document, attachments) {
|
975
978
|
const body = new FormData();
|
976
979
|
attachments.forEach(attachment => {
|
@@ -981,6 +984,24 @@ class DocumentTemplatesApiService {
|
|
981
984
|
responseType: 'arraybuffer',
|
982
985
|
});
|
983
986
|
}
|
987
|
+
generateDocumentRequest(document, attachments, quoteId, isAsync) {
|
988
|
+
const formData = new FormData();
|
989
|
+
attachments.forEach(attachment => {
|
990
|
+
formData.append('attachments', new Blob([attachment]));
|
991
|
+
});
|
992
|
+
formData.append('orderform', document);
|
993
|
+
const params = {};
|
994
|
+
if (isAsync) {
|
995
|
+
params['async'] = 'true';
|
996
|
+
}
|
997
|
+
return this.service.upload({
|
998
|
+
method: 'post',
|
999
|
+
url: `/docgen/${quoteId}/generate`,
|
1000
|
+
body: formData,
|
1001
|
+
params,
|
1002
|
+
responseType: 'arraybuffer',
|
1003
|
+
});
|
1004
|
+
}
|
984
1005
|
getAttachments(searchRequest) {
|
985
1006
|
return this.documentAttachmentService.getAttachments(searchRequest);
|
986
1007
|
}
|
@@ -1009,7 +1030,7 @@ class DocumentTemplatesApiService {
|
|
1009
1030
|
...templateProperties,
|
1010
1031
|
});
|
1011
1032
|
}
|
1012
|
-
generateDocument(template, object, params = {}) {
|
1033
|
+
generateDocument(template, object, params = {}, quoteId, isAsync) {
|
1013
1034
|
const documentData$ = this.generateDocumentData(template, object, { ...params, shouldPreventDownload: true });
|
1014
1035
|
return zip(this.getTemplateFile(template.id), documentData$, this.resolveAttachments$(template)).pipe(switchMap(([templateFile, data, attachments]) => {
|
1015
1036
|
const document = DocxTemplater.generate(templateFile, data);
|
@@ -1022,22 +1043,9 @@ class DocumentTemplatesApiService {
|
|
1022
1043
|
this.fileDownloadService.processDownload(document, documentName);
|
1023
1044
|
return of(document);
|
1024
1045
|
}
|
1025
|
-
return this.
|
1026
|
-
if (params.attachToQuote && QuoteDraft.isQuote(object)) {
|
1027
|
-
const file = new File([pdf], `${documentName}.pdf`);
|
1028
|
-
return this.documentAttachmentService
|
1029
|
-
.createAttachment({
|
1030
|
-
linkedEntityId: object.quoteId,
|
1031
|
-
fileName: documentName,
|
1032
|
-
fileExtension: 'pdf',
|
1033
|
-
tags: this.DOCGEN_TAG,
|
1034
|
-
}, file)
|
1035
|
-
.pipe(map(() => pdf));
|
1036
|
-
}
|
1037
|
-
return of(pdf);
|
1038
|
-
}), map(pdf => {
|
1046
|
+
return this.generateDocumentRequest(document, attachments, quoteId, isAsync).pipe(map(pdf => {
|
1039
1047
|
const blob = new Blob([pdf]);
|
1040
|
-
if (!params.shouldPreventDownload) {
|
1048
|
+
if (!isAsync && !params.shouldPreventDownload) {
|
1041
1049
|
this.fileDownloadService.processDownload(blob, `${documentName}.pdf`);
|
1042
1050
|
}
|
1043
1051
|
return blob;
|