@veloceapps/api 9.0.0-1 → 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/configuration-api.service.mjs +26 -28
- package/esm2020/lib/services/document-templates-api.service.mjs +27 -19
- package/fesm2015/veloceapps-api.mjs +51 -42
- package/fesm2015/veloceapps-api.mjs.map +1 -1
- package/fesm2020/veloceapps-api.mjs +51 -45
- package/fesm2020/veloceapps-api.mjs.map +1 -1
- package/lib/services/configuration-api.service.d.ts +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';
|
@@ -403,7 +403,7 @@ class ConfigurationApiService {
|
|
403
403
|
if (runtimeModel) {
|
404
404
|
return {
|
405
405
|
...configurePrice,
|
406
|
-
lineItem: this.
|
406
|
+
lineItem: this.updateDomains(configurePrice.lineItem, runtimeModel),
|
407
407
|
};
|
408
408
|
}
|
409
409
|
else {
|
@@ -423,7 +423,7 @@ class ConfigurationApiService {
|
|
423
423
|
if (runtimeModel) {
|
424
424
|
return {
|
425
425
|
...configurePrice,
|
426
|
-
lineItem: this.
|
426
|
+
lineItem: this.updateDomains(configurePrice.lineItem, runtimeModel),
|
427
427
|
};
|
428
428
|
}
|
429
429
|
else {
|
@@ -450,37 +450,35 @@ class ConfigurationApiService {
|
|
450
450
|
url: `${this.SERVICE_URL}/${modelId}/model-test`,
|
451
451
|
});
|
452
452
|
}
|
453
|
-
|
454
|
-
const
|
453
|
+
updateDomains(lineItem, runtimeModel) {
|
454
|
+
const component = runtimeModel.components.get(lineItem.type);
|
455
455
|
const portDomains = { ...lineItem.portDomains };
|
456
456
|
// loop through ports to look for 'None' type domain computations
|
457
|
-
for (const port of
|
458
|
-
const
|
459
|
-
|
460
|
-
|
461
|
-
// there's a 'None' type domain computation
|
462
|
-
if (portDomain.properties?.['domainComputation'] === ('None')) {
|
463
|
-
portDomain.domainTypes = domainTypes;
|
464
|
-
}
|
465
|
-
}
|
466
|
-
else {
|
467
|
-
// there's no port domain so consider that as 'None' type domain computation
|
468
|
-
portDomains[portName] = {
|
469
|
-
name: portName,
|
470
|
-
type: typeName,
|
471
|
-
minCard: Number(min),
|
472
|
-
maxCard: Number(max),
|
473
|
-
domainTypes: domainTypes,
|
474
|
-
properties: {
|
475
|
-
...properties,
|
476
|
-
domainComputation: 'None',
|
477
|
-
},
|
478
|
-
};
|
457
|
+
for (const port of component?.ports ?? []) {
|
458
|
+
const portDomain = portDomains[port.name];
|
459
|
+
if (portDomain?.properties?.['domainComputation'] === ('None')) {
|
460
|
+
portDomain.domainTypes = port.domainTypes;
|
479
461
|
}
|
480
462
|
}
|
463
|
+
const type = runtimeModel.types.find(({ name }) => {
|
464
|
+
return lineItem.type === name;
|
465
|
+
});
|
466
|
+
const attributeDomains = lineItem.attributeDomains;
|
467
|
+
if (type) {
|
468
|
+
const initialDomains = lineItem.attributeDomains;
|
469
|
+
type.attributes.forEach(attribute => {
|
470
|
+
if (Object.prototype.hasOwnProperty.call(initialDomains, attribute.name)) {
|
471
|
+
return;
|
472
|
+
}
|
473
|
+
if (attribute.attributeDomain) {
|
474
|
+
attributeDomains[attribute.name] = attribute.attributeDomain;
|
475
|
+
}
|
476
|
+
});
|
477
|
+
}
|
481
478
|
return {
|
482
479
|
...lineItem,
|
483
|
-
lineItems: lineItem.lineItems?.map(i => this.
|
480
|
+
lineItems: lineItem.lineItems?.map(i => this.updateDomains(i, runtimeModel)),
|
481
|
+
attributeDomains,
|
484
482
|
portDomains,
|
485
483
|
};
|
486
484
|
}
|
@@ -870,8 +868,8 @@ class DocumentTemplatesApiService {
|
|
870
868
|
this.fileDownloadService = fileDownloadService;
|
871
869
|
this.documentAttachmentService = documentAttachmentService;
|
872
870
|
this.http = http;
|
873
|
-
this.DOCGEN_TAG = 'docgen';
|
874
871
|
this.SERVICE_URL = '/templates';
|
872
|
+
this.DOCGEN_TAG = 'docgen';
|
875
873
|
this.DOC_GEN_URL_FALLBACK = `${window.VELO_API}/docgen`;
|
876
874
|
this.mapSfQueryResult = (limit) => map((records) => {
|
877
875
|
if (!records.length) {
|
@@ -973,6 +971,9 @@ class DocumentTemplatesApiService {
|
|
973
971
|
this.fileDownloadService.processDownload(response);
|
974
972
|
}), map(response => response.body || response));
|
975
973
|
}
|
974
|
+
/**
|
975
|
+
* @deprecated
|
976
|
+
*/
|
976
977
|
mergeDocuments(document, attachments) {
|
977
978
|
const body = new FormData();
|
978
979
|
attachments.forEach(attachment => {
|
@@ -983,6 +984,24 @@ class DocumentTemplatesApiService {
|
|
983
984
|
responseType: 'arraybuffer',
|
984
985
|
});
|
985
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
|
+
}
|
986
1005
|
getAttachments(searchRequest) {
|
987
1006
|
return this.documentAttachmentService.getAttachments(searchRequest);
|
988
1007
|
}
|
@@ -1011,7 +1030,7 @@ class DocumentTemplatesApiService {
|
|
1011
1030
|
...templateProperties,
|
1012
1031
|
});
|
1013
1032
|
}
|
1014
|
-
generateDocument(template, object, params = {}) {
|
1033
|
+
generateDocument(template, object, params = {}, quoteId, isAsync) {
|
1015
1034
|
const documentData$ = this.generateDocumentData(template, object, { ...params, shouldPreventDownload: true });
|
1016
1035
|
return zip(this.getTemplateFile(template.id), documentData$, this.resolveAttachments$(template)).pipe(switchMap(([templateFile, data, attachments]) => {
|
1017
1036
|
const document = DocxTemplater.generate(templateFile, data);
|
@@ -1024,22 +1043,9 @@ class DocumentTemplatesApiService {
|
|
1024
1043
|
this.fileDownloadService.processDownload(document, documentName);
|
1025
1044
|
return of(document);
|
1026
1045
|
}
|
1027
|
-
return this.
|
1028
|
-
if (params.attachToQuote && QuoteDraft.isQuote(object)) {
|
1029
|
-
const file = new File([pdf], `${documentName}.pdf`);
|
1030
|
-
return this.documentAttachmentService
|
1031
|
-
.createAttachment({
|
1032
|
-
linkedEntityId: object.quoteId,
|
1033
|
-
fileName: documentName,
|
1034
|
-
fileExtension: 'pdf',
|
1035
|
-
tags: this.DOCGEN_TAG,
|
1036
|
-
}, file)
|
1037
|
-
.pipe(map(() => pdf));
|
1038
|
-
}
|
1039
|
-
return of(pdf);
|
1040
|
-
}), map(pdf => {
|
1046
|
+
return this.generateDocumentRequest(document, attachments, quoteId, isAsync).pipe(map(pdf => {
|
1041
1047
|
const blob = new Blob([pdf]);
|
1042
|
-
if (!params.shouldPreventDownload) {
|
1048
|
+
if (!isAsync && !params.shouldPreventDownload) {
|
1043
1049
|
this.fileDownloadService.processDownload(blob, `${documentName}.pdf`);
|
1044
1050
|
}
|
1045
1051
|
return blob;
|