@veloceapps/api 2.0.15 → 2.0.16
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/bundles/veloce-api.umd.js +227 -228
- package/bundles/veloce-api.umd.js.map +1 -1
- package/esm2015/lib/services/document-attachment-api.service.js +7 -6
- package/esm2015/lib/services/document-templates-api.service.js +143 -154
- package/esm2015/lib/services/quote-api.service.js +12 -1
- package/esm2015/lib/services/rules-api.service.js +2 -2
- package/fesm2015/veloce-api.js +190 -190
- package/fesm2015/veloce-api.js.map +1 -1
- package/lib/services/document-attachment-api.service.d.ts +1 -0
- package/lib/services/document-templates-api.service.d.ts +22 -16
- package/lib/services/quote-api.service.d.ts +1 -0
- package/package.json +1 -1
@@ -2,7 +2,7 @@
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common/http'), require('@angular/core'), require('@veloce/core'), require('rxjs'), require('rxjs/operators'), require('lodash'), require('@angular/common'), require('moment')) :
|
3
3
|
typeof define === 'function' && define.amd ? define('@veloce/api', ['exports', '@angular/common/http', '@angular/core', '@veloce/core', 'rxjs', 'rxjs/operators', 'lodash', '@angular/common', 'moment'], factory) :
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.veloce = global.veloce || {}, global.veloce.api = {}), global.ng.common.http, global.ng.core, global["@veloce/core"], global.rxjs, global.rxjs.operators, global.lodash, global.ng.common, global.moment));
|
5
|
-
})(this, (function (exports,
|
5
|
+
})(this, (function (exports, i5, i0, i1, rxjs, operators, _, common, moment_) { 'use strict';
|
6
6
|
|
7
7
|
function _interopNamespace(e) {
|
8
8
|
if (e && e.__esModule) return e;
|
@@ -22,7 +22,7 @@
|
|
22
22
|
return Object.freeze(n);
|
23
23
|
}
|
24
24
|
|
25
|
-
var
|
25
|
+
var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
|
26
26
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
27
27
|
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
28
28
|
var ___namespace = /*#__PURE__*/_interopNamespace(_);
|
@@ -903,10 +903,11 @@
|
|
903
903
|
function DocumentAttachmentApiService(httpService, fileDownloadService) {
|
904
904
|
this.httpService = httpService;
|
905
905
|
this.fileDownloadService = fileDownloadService;
|
906
|
+
this.SERVICE_URL = '/attachments';
|
906
907
|
}
|
907
908
|
DocumentAttachmentApiService.prototype.getAttachments = function (searchRequest) {
|
908
909
|
return this.httpService.api({
|
909
|
-
url:
|
910
|
+
url: this.SERVICE_URL + "/search",
|
910
911
|
method: 'post',
|
911
912
|
body: searchRequest,
|
912
913
|
});
|
@@ -920,7 +921,7 @@
|
|
920
921
|
type: 'application/json',
|
921
922
|
}));
|
922
923
|
return this.httpService.upload({
|
923
|
-
url: "
|
924
|
+
url: "" + this.SERVICE_URL,
|
924
925
|
body: formData,
|
925
926
|
method: 'post',
|
926
927
|
observe: reportProgress ? 'events' : undefined,
|
@@ -929,7 +930,7 @@
|
|
929
930
|
};
|
930
931
|
DocumentAttachmentApiService.prototype.updateAttachment = function (id, attachment) {
|
931
932
|
return this.httpService.api({
|
932
|
-
url: "/
|
933
|
+
url: this.SERVICE_URL + "/" + id,
|
933
934
|
body: attachment,
|
934
935
|
method: 'put',
|
935
936
|
});
|
@@ -938,7 +939,7 @@
|
|
938
939
|
var _this = this;
|
939
940
|
return this.httpService
|
940
941
|
.api({
|
941
|
-
url: "/
|
942
|
+
url: this.SERVICE_URL + "/" + id + "/file",
|
942
943
|
responseType: isPreventDownload ? 'arraybuffer' : 'blob',
|
943
944
|
observe: isPreventDownload ? 'body' : 'response',
|
944
945
|
})
|
@@ -950,7 +951,7 @@
|
|
950
951
|
};
|
951
952
|
DocumentAttachmentApiService.prototype.removeAttachment = function (id) {
|
952
953
|
return this.httpService.api({
|
953
|
-
url: "/
|
954
|
+
url: this.SERVICE_URL + "/" + id,
|
954
955
|
method: 'delete',
|
955
956
|
});
|
956
957
|
};
|
@@ -975,7 +976,7 @@
|
|
975
976
|
});
|
976
977
|
};
|
977
978
|
SalesforceApiService.prototype.queryObjects = function (search) {
|
978
|
-
var params = new
|
979
|
+
var params = new i5.HttpParams();
|
979
980
|
if (search) {
|
980
981
|
params.append('search', search);
|
981
982
|
}
|
@@ -1010,48 +1011,101 @@
|
|
1010
1011
|
type: i0.Injectable
|
1011
1012
|
}], ctorParameters: function () { return [{ type: i1__namespace.BaseHttpService }]; } });
|
1012
1013
|
|
1013
|
-
var
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
}
|
1018
|
-
if (limit === 1) {
|
1019
|
-
return records[0];
|
1020
|
-
}
|
1021
|
-
return records;
|
1022
|
-
}); };
|
1023
|
-
var mapBooleanIfAplicable = function (value) {
|
1024
|
-
if (value === 'true') {
|
1025
|
-
return true;
|
1026
|
-
}
|
1027
|
-
if (value === 'false') {
|
1028
|
-
return false;
|
1014
|
+
var QuoteApiService = /** @class */ (function () {
|
1015
|
+
function QuoteApiService(httpService) {
|
1016
|
+
this.httpService = httpService;
|
1017
|
+
this.SERVICE_URL = '/quotes';
|
1029
1018
|
}
|
1030
|
-
|
1031
|
-
|
1019
|
+
QuoteApiService.prototype.getQuote = function (quoteId, params) {
|
1020
|
+
return this.httpService.api({
|
1021
|
+
method: 'get',
|
1022
|
+
url: this.SERVICE_URL + "/" + quoteId,
|
1023
|
+
params: params,
|
1024
|
+
});
|
1025
|
+
};
|
1026
|
+
QuoteApiService.prototype.upsertQuote = function (request) {
|
1027
|
+
return this.httpService.api({
|
1028
|
+
method: 'post',
|
1029
|
+
url: "" + this.SERVICE_URL,
|
1030
|
+
body: request,
|
1031
|
+
});
|
1032
|
+
};
|
1033
|
+
QuoteApiService.prototype.submitQuote = function (request) {
|
1034
|
+
return this.httpService.api({
|
1035
|
+
method: 'post',
|
1036
|
+
url: this.SERVICE_URL + "/submit",
|
1037
|
+
body: request,
|
1038
|
+
});
|
1039
|
+
};
|
1040
|
+
QuoteApiService.prototype.attachDocument = function (id, documentName, data) {
|
1041
|
+
var formData = new FormData();
|
1042
|
+
var blob = new Blob([data]);
|
1043
|
+
formData.append('file', blob, documentName);
|
1044
|
+
return this.httpService.upload({
|
1045
|
+
url: this.SERVICE_URL + "/" + id + "/attach-document",
|
1046
|
+
responseType: 'arraybuffer',
|
1047
|
+
method: 'post',
|
1048
|
+
body: formData,
|
1049
|
+
});
|
1050
|
+
};
|
1051
|
+
return QuoteApiService;
|
1052
|
+
}());
|
1053
|
+
QuoteApiService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteApiService, deps: [{ token: i1__namespace.BaseHttpService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1054
|
+
QuoteApiService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteApiService });
|
1055
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteApiService, decorators: [{
|
1056
|
+
type: i0.Injectable
|
1057
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.BaseHttpService }]; } });
|
1058
|
+
|
1059
|
+
var moment = moment___namespace;
|
1032
1060
|
var DocumentTemplatesApiService = /** @class */ (function () {
|
1033
|
-
function DocumentTemplatesApiService(service,
|
1061
|
+
function DocumentTemplatesApiService(service, salesforceApiService, fileDownloadService, documentAttachmentService, quoteApiService, http) {
|
1034
1062
|
this.service = service;
|
1035
|
-
this.
|
1063
|
+
this.salesforceApiService = salesforceApiService;
|
1036
1064
|
this.fileDownloadService = fileDownloadService;
|
1037
1065
|
this.documentAttachmentService = documentAttachmentService;
|
1066
|
+
this.quoteApiService = quoteApiService;
|
1038
1067
|
this.http = http;
|
1039
|
-
this.
|
1068
|
+
this.SERVICE_URL = '/templates';
|
1069
|
+
this.DOC_GEN_URL_FALLBACK = 'https://dev-dp1.velocpq.com/docgen';
|
1070
|
+
this.mapSfQueryResult = function (limit) { return operators.map(function (records) {
|
1071
|
+
if (!records.length) {
|
1072
|
+
return { _result: 'No Records Found' };
|
1073
|
+
}
|
1074
|
+
if (limit === 1) {
|
1075
|
+
return records[0];
|
1076
|
+
}
|
1077
|
+
return records;
|
1078
|
+
}); };
|
1079
|
+
this.mapBooleanIfAplicable = function (value) {
|
1080
|
+
if (value === 'true') {
|
1081
|
+
return true;
|
1082
|
+
}
|
1083
|
+
if (value === 'false') {
|
1084
|
+
return false;
|
1085
|
+
}
|
1086
|
+
return value;
|
1087
|
+
};
|
1040
1088
|
if (window.VELO_DOCGEN_API) {
|
1041
|
-
this.
|
1089
|
+
this.DOC_GEN_URL = window.VELO_DOCGEN_API;
|
1042
1090
|
}
|
1043
1091
|
else {
|
1044
|
-
console.log("window.VELO_DOCGEN_API not set, will use fallback \"" + this.
|
1045
|
-
this.
|
1092
|
+
console.log("window.VELO_DOCGEN_API not set, will use fallback \"" + this.DOC_GEN_URL_FALLBACK + "\"");
|
1093
|
+
this.DOC_GEN_URL = this.DOC_GEN_URL_FALLBACK;
|
1046
1094
|
}
|
1047
1095
|
}
|
1048
1096
|
DocumentTemplatesApiService.prototype.getTemplates = function (tag) {
|
1049
1097
|
return this.service.api({
|
1050
|
-
url:
|
1098
|
+
url: "" + this.SERVICE_URL,
|
1051
1099
|
method: 'get',
|
1052
1100
|
params: Object.assign({}, (tag && { tag: tag })),
|
1053
1101
|
});
|
1054
1102
|
};
|
1103
|
+
DocumentTemplatesApiService.prototype.getTemplate = function (id) {
|
1104
|
+
return this.service.api({
|
1105
|
+
url: this.SERVICE_URL + "/" + id,
|
1106
|
+
method: 'get',
|
1107
|
+
});
|
1108
|
+
};
|
1055
1109
|
DocumentTemplatesApiService.prototype.upsertTemplate = function (template, file, reportProgress) {
|
1056
1110
|
var formData = new FormData();
|
1057
1111
|
if (file) {
|
@@ -1060,8 +1114,12 @@
|
|
1060
1114
|
formData.append('template', new Blob([JSON.stringify(template)], {
|
1061
1115
|
type: 'application/json',
|
1062
1116
|
}));
|
1117
|
+
var url = "" + this.SERVICE_URL;
|
1118
|
+
if (template.id) {
|
1119
|
+
url += "/" + template.id;
|
1120
|
+
}
|
1063
1121
|
return this.service.upload({
|
1064
|
-
url:
|
1122
|
+
url: url,
|
1065
1123
|
body: formData,
|
1066
1124
|
method: template.id ? 'put' : 'post',
|
1067
1125
|
reportProgress: reportProgress,
|
@@ -1069,20 +1127,20 @@
|
|
1069
1127
|
};
|
1070
1128
|
DocumentTemplatesApiService.prototype.removeTemplate = function (id) {
|
1071
1129
|
return this.service.api({
|
1072
|
-
url:
|
1130
|
+
url: this.SERVICE_URL + "/" + id,
|
1073
1131
|
method: 'delete',
|
1074
1132
|
});
|
1075
1133
|
};
|
1076
1134
|
DocumentTemplatesApiService.prototype.restoreTemplate = function (id) {
|
1077
1135
|
return this.service.api({
|
1078
|
-
url: "/
|
1136
|
+
url: this.SERVICE_URL + "/" + id + "/restore",
|
1079
1137
|
method: 'patch',
|
1080
1138
|
});
|
1081
1139
|
};
|
1082
1140
|
DocumentTemplatesApiService.prototype.cloneTemplate = function (id, propertiesToOverride) {
|
1083
1141
|
if (propertiesToOverride === void 0) { propertiesToOverride = {}; }
|
1084
1142
|
return this.service.api({
|
1085
|
-
url:
|
1143
|
+
url: this.SERVICE_URL + "/clone/" + id,
|
1086
1144
|
method: 'post',
|
1087
1145
|
body: {
|
1088
1146
|
id: id,
|
@@ -1090,19 +1148,105 @@
|
|
1090
1148
|
},
|
1091
1149
|
});
|
1092
1150
|
};
|
1151
|
+
DocumentTemplatesApiService.prototype.getTemplateFile = function (id) {
|
1152
|
+
return this.service.api({
|
1153
|
+
method: 'get',
|
1154
|
+
url: this.SERVICE_URL + "/" + id + "/file",
|
1155
|
+
responseType: 'arraybuffer',
|
1156
|
+
});
|
1157
|
+
};
|
1158
|
+
DocumentTemplatesApiService.prototype.downloadTemplateFile = function (id) {
|
1159
|
+
var _this = this;
|
1160
|
+
return this.service
|
1161
|
+
.api({
|
1162
|
+
url: this.SERVICE_URL + "/" + id + "/file",
|
1163
|
+
responseType: 'blob',
|
1164
|
+
observe: 'response',
|
1165
|
+
})
|
1166
|
+
.pipe(operators.tap(function (response) {
|
1167
|
+
_this.fileDownloadService.processDownload(response);
|
1168
|
+
}), operators.map(function (response) { return response.body || response; }));
|
1169
|
+
};
|
1170
|
+
DocumentTemplatesApiService.prototype.mergeDocuments = function (document, attachments) {
|
1171
|
+
var body = new FormData();
|
1172
|
+
attachments.forEach(function (attachment) {
|
1173
|
+
body.append('attachments', new Blob([attachment]));
|
1174
|
+
});
|
1175
|
+
body.append('orderform', document);
|
1176
|
+
return this.http.post(this.DOC_GEN_URL + "/documents/merge", body, {
|
1177
|
+
responseType: 'arraybuffer',
|
1178
|
+
});
|
1179
|
+
};
|
1180
|
+
DocumentTemplatesApiService.prototype.getAttachments = function (searchRequest) {
|
1181
|
+
return this.documentAttachmentService.getAttachments(searchRequest);
|
1182
|
+
};
|
1183
|
+
DocumentTemplatesApiService.prototype.getAttachmentFile = function (id) {
|
1184
|
+
return this.documentAttachmentService.getAttachmentFile(id);
|
1185
|
+
};
|
1186
|
+
DocumentTemplatesApiService.prototype.createAttachment = function (attachment, file, reportProgress) {
|
1187
|
+
return this.documentAttachmentService.createAttachment(attachment, file, reportProgress);
|
1188
|
+
};
|
1189
|
+
DocumentTemplatesApiService.prototype.removeAttachment = function (id) {
|
1190
|
+
return this.documentAttachmentService.removeAttachment(id);
|
1191
|
+
};
|
1093
1192
|
DocumentTemplatesApiService.prototype.generateDocumentData = function (template, object, params) {
|
1094
1193
|
var _this = this;
|
1095
|
-
|
1096
|
-
var
|
1097
|
-
|
1098
|
-
|
1099
|
-
return name === 'useLocalDataGeneration';
|
1100
|
-
})) === null || _b === void 0 ? void 0 : _b.value;
|
1101
|
-
if (!useLocalDataGeneration && object instanceof i1.QuoteDraft) {
|
1102
|
-
return this.generate('/templates/generate-data', { template: template, quote: object }, shouldPreventDownload, shouldPreventDownload ? 'json' : 'blob');
|
1194
|
+
if (params === void 0) { params = {}; }
|
1195
|
+
var _a;
|
1196
|
+
if (i1.isLegacyDocumentTemplate(template)) {
|
1197
|
+
return this.generateDocumentDataLegacy(template, object, params);
|
1103
1198
|
}
|
1104
|
-
var
|
1105
|
-
|
1199
|
+
var templateProperties = (_a = template.properties) === null || _a === void 0 ? void 0 : _a.reduce(function (acc, _g) {
|
1200
|
+
var _h;
|
1201
|
+
var name = _g.name, value = _g.value;
|
1202
|
+
return (Object.assign(Object.assign({}, acc), (_h = {}, _h[name] = _this.mapBooleanIfAplicable(value), _h)));
|
1203
|
+
}, {});
|
1204
|
+
/*
|
1205
|
+
Resolve quote and template properties for now
|
1206
|
+
When procedures are ready, whey will replace template scripts.
|
1207
|
+
|
1208
|
+
TODO: run procedure to resolve document data
|
1209
|
+
*/
|
1210
|
+
return rxjs.of(Object.assign(Object.assign({}, (typeof object === 'object' ? object : { object: object })), templateProperties));
|
1211
|
+
};
|
1212
|
+
DocumentTemplatesApiService.prototype.generateDocument = function (template, object, params) {
|
1213
|
+
var _this = this;
|
1214
|
+
if (params === void 0) { params = {}; }
|
1215
|
+
var documentData$ = this.generateDocumentData(template, object, Object.assign(Object.assign({}, params), { shouldPreventDownload: true }));
|
1216
|
+
return rxjs.zip(this.getTemplateFile(template.id), documentData$, this.resolveAttachments$(template)).pipe(operators.switchMap(function (_g) {
|
1217
|
+
var _h = __read(_g, 3), templateFile = _h[0], data = _h[1], attachments = _h[2];
|
1218
|
+
var _a, _b, _c, _d, _e, _f;
|
1219
|
+
var document = i1.DocxTemplater.generate(templateFile, data);
|
1220
|
+
var properties = (_c = (_b = (_a = object === null || object === void 0 ? void 0 : object.context) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : object === null || object === void 0 ? void 0 : object.properties) !== null && _c !== void 0 ? _c : {};
|
1221
|
+
var documentName = properties.Name || template.name;
|
1222
|
+
var documentFormat = (_d = params.documentFormat) !== null && _d !== void 0 ? _d : (_f = (_e = template.properties) === null || _e === void 0 ? void 0 : _e.find(function (p) { return p.name === 'documentFormat'; })) === null || _f === void 0 ? void 0 : _f.value;
|
1223
|
+
if (documentFormat === 'DOCX') {
|
1224
|
+
_this.fileDownloadService.processDownload(document, documentName);
|
1225
|
+
return rxjs.of(document);
|
1226
|
+
}
|
1227
|
+
return _this.mergeDocuments(document, attachments).pipe(operators.switchMap(function (pdf) {
|
1228
|
+
if (params.attachToQuote && i1.QuoteDraft.isQuote(object)) {
|
1229
|
+
return _this.quoteApiService
|
1230
|
+
.attachDocument(object.quoteId, documentName + ".pdf", pdf)
|
1231
|
+
.pipe(operators.map(function () { return pdf; }));
|
1232
|
+
}
|
1233
|
+
return rxjs.of(pdf);
|
1234
|
+
}), operators.map(function (pdf) {
|
1235
|
+
var blob = new Blob([pdf]);
|
1236
|
+
if (!params.shouldPreventDownload) {
|
1237
|
+
_this.fileDownloadService.processDownload(blob, documentName + ".pdf");
|
1238
|
+
}
|
1239
|
+
return blob;
|
1240
|
+
}));
|
1241
|
+
}));
|
1242
|
+
};
|
1243
|
+
DocumentTemplatesApiService.prototype.generateDocumentDataLegacy = function (template, object, params) {
|
1244
|
+
var _this = this;
|
1245
|
+
if (params === void 0) { params = {}; }
|
1246
|
+
var _a, _b, _c, _d;
|
1247
|
+
var shouldPreventDownload = params.shouldPreventDownload;
|
1248
|
+
var allQueries = __spreadArray([], __read(((_a = template === null || template === void 0 ? void 0 : template.queries) !== null && _a !== void 0 ? _a : [])));
|
1249
|
+
var properties = (_d = (_c = (_b = object === null || object === void 0 ? void 0 : object.context) === null || _b === void 0 ? void 0 : _b.properties) !== null && _c !== void 0 ? _c : object === null || object === void 0 ? void 0 : object.properties) !== null && _d !== void 0 ? _d : {};
|
1106
1250
|
var accountId = properties === null || properties === void 0 ? void 0 : properties.AccountId;
|
1107
1251
|
var userId = properties === null || properties === void 0 ? void 0 : properties.UserId;
|
1108
1252
|
if (accountId) {
|
@@ -1124,9 +1268,7 @@
|
|
1124
1268
|
});
|
1125
1269
|
}
|
1126
1270
|
var queries = allQueries.map(function (query) { return _this.queryObject(query, { properties: properties }); }) || [];
|
1127
|
-
return rxjs.forkJoin(__spreadArray([], __read(queries)))
|
1128
|
-
.pipe(operators.defaultIfEmpty([]))
|
1129
|
-
.pipe(operators.map(function (results) {
|
1271
|
+
return rxjs.forkJoin(__spreadArray([], __read(queries))).pipe(operators.defaultIfEmpty([]), operators.map(function (results) {
|
1130
1272
|
var _a, _b, _c, _d;
|
1131
1273
|
var queriesResult = ___namespace.chain(results)
|
1132
1274
|
.reduce(function (acc, r) {
|
@@ -1136,19 +1278,19 @@
|
|
1136
1278
|
return acc;
|
1137
1279
|
}, {})
|
1138
1280
|
.value();
|
1139
|
-
var templateProperties = ((template === null || template === void 0 ? void 0 : template.properties) || []).reduce(function (trunk,
|
1140
|
-
var
|
1141
|
-
var name =
|
1142
|
-
return Object.assign(Object.assign({}, trunk), (
|
1281
|
+
var templateProperties = ((template === null || template === void 0 ? void 0 : template.properties) || []).reduce(function (trunk, _g) {
|
1282
|
+
var _h;
|
1283
|
+
var name = _g.name, value = _g.value;
|
1284
|
+
return Object.assign(Object.assign({}, trunk), (_h = {}, _h[name] = _this.mapBooleanIfAplicable(value), _h));
|
1143
1285
|
}, {});
|
1144
1286
|
var data = Object.assign(Object.assign(Object.assign({}, (typeof object === 'object' ? object : { object: object })), queriesResult), templateProperties);
|
1145
1287
|
if (template.script && template.script.trim().length) {
|
1146
|
-
var currencyFormat_1 = ((_b = (_a = template.properties) === null || _a === void 0 ? void 0 : _a.find(function (
|
1147
|
-
var name =
|
1288
|
+
var currencyFormat_1 = ((_b = (_a = template.properties) === null || _a === void 0 ? void 0 : _a.find(function (_g) {
|
1289
|
+
var name = _g.name;
|
1148
1290
|
return name === 'currencyFormat';
|
1149
1291
|
})) === null || _b === void 0 ? void 0 : _b.value) || '1.2-2';
|
1150
|
-
var dateFormat_1 = ((_d = (_c = template.properties) === null || _c === void 0 ? void 0 : _c.find(function (
|
1151
|
-
var name =
|
1292
|
+
var dateFormat_1 = ((_d = (_c = template.properties) === null || _c === void 0 ? void 0 : _c.find(function (_g) {
|
1293
|
+
var name = _g.name;
|
1152
1294
|
return name === 'dateFormat';
|
1153
1295
|
})) === null || _d === void 0 ? void 0 : _d.value) || 'D/MMM/YYYY';
|
1154
1296
|
var formatDate = function (value) {
|
@@ -1169,130 +1311,21 @@
|
|
1169
1311
|
return data;
|
1170
1312
|
}));
|
1171
1313
|
};
|
1172
|
-
DocumentTemplatesApiService.prototype.
|
1173
|
-
if (params === void 0) { params = {}; }
|
1174
|
-
var attachmentIds = (template.attachments || []).map(function (_e) {
|
1175
|
-
var id = _e.id;
|
1176
|
-
return id;
|
1177
|
-
}).filter(Boolean);
|
1178
|
-
var shouldUseLocalDocxTemplater = params.shouldUseLocalDocxTemplater;
|
1179
|
-
return shouldUseLocalDocxTemplater && !(object instanceof i1.QuoteDraft)
|
1180
|
-
? this.generateDocumentNew(template, object, params)
|
1181
|
-
: this.generateWithBackendDocxTemplater({ template: template, quote: object, attachmentIds: attachmentIds, params: params });
|
1182
|
-
};
|
1183
|
-
DocumentTemplatesApiService.prototype.generateDocumentNew = function (template, object, params) {
|
1314
|
+
DocumentTemplatesApiService.prototype.resolveAttachments$ = function (template) {
|
1184
1315
|
var _this = this;
|
1185
|
-
|
1186
|
-
var
|
1187
|
-
|
1188
|
-
method: 'get',
|
1189
|
-
url: "/templates/" + template.id + "/file",
|
1190
|
-
responseType: 'arraybuffer',
|
1191
|
-
});
|
1192
|
-
var attachmentIds = (template.attachments || []).map(function (_e) {
|
1193
|
-
var id = _e.id;
|
1316
|
+
var _a, _b;
|
1317
|
+
var attachmentIds = (_b = (_a = template.attachments) === null || _a === void 0 ? void 0 : _a.map(function (_g) {
|
1318
|
+
var id = _g.id;
|
1194
1319
|
return id;
|
1195
|
-
});
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
: [];
|
1201
|
-
var data$ = this.generateDocumentData(template, object, Object.assign(Object.assign({}, params), { shouldPreventDownload: true }));
|
1202
|
-
return rxjs.zip.apply(void 0, __spreadArray([file$, data$], __read(attachments$))).pipe(operators.switchMap(function (_e) {
|
1203
|
-
var _f = __read(_e), file = _f[0], data = _f[1], attachments = _f.slice(2);
|
1204
|
-
var _a;
|
1205
|
-
var d = i1.DocxTemplater.generate(file, data);
|
1206
|
-
var body = new FormData();
|
1207
|
-
var properties = ((_a = object === null || object === void 0 ? void 0 : object.context) === null || _a === void 0 ? void 0 : _a.properties) || (object === null || object === void 0 ? void 0 : object.properties) || {};
|
1208
|
-
var documentName = (properties === null || properties === void 0 ? void 0 : properties.Name) || template.name;
|
1209
|
-
// TODO: special CATO case. Refactor for a more generic approach
|
1210
|
-
if (documentFormat === 'DOCX') {
|
1211
|
-
_this.fileDownloadService.processDownload(d, documentName);
|
1212
|
-
return rxjs.of(d);
|
1213
|
-
}
|
1214
|
-
attachments.forEach(function (attachment) {
|
1215
|
-
body.append('attachments', new Blob([attachment]));
|
1216
|
-
});
|
1217
|
-
body.append('orderform', d);
|
1218
|
-
return _this.http
|
1219
|
-
.post(_this.docGenHost + "/documents/merge", body, {
|
1220
|
-
responseType: 'arraybuffer',
|
1221
|
-
})
|
1222
|
-
.pipe(operators.switchMap(function (pdf) {
|
1223
|
-
var blob = new Blob([pdf]);
|
1224
|
-
if (!shouldPreventDownload) {
|
1225
|
-
_this.fileDownloadService.processDownload(blob, documentName + ".pdf");
|
1226
|
-
}
|
1227
|
-
if (attachToQuote && object instanceof i1.QuoteDraft) {
|
1228
|
-
var formData = new FormData();
|
1229
|
-
formData.append('file', blob, documentName + ".pdf");
|
1230
|
-
return _this.http.post(window['VELO_API'] + "/services/quotes/" + object.quoteId + "/attach-document", formData, {
|
1231
|
-
responseType: 'arraybuffer',
|
1232
|
-
headers: {
|
1233
|
-
Authorization: window['VELO_KEY'],
|
1234
|
-
},
|
1235
|
-
});
|
1236
|
-
}
|
1237
|
-
return rxjs.of(blob);
|
1238
|
-
}));
|
1239
|
-
}));
|
1240
|
-
};
|
1241
|
-
DocumentTemplatesApiService.prototype.getAttachments = function (searchRequest) {
|
1242
|
-
return this.documentAttachmentService.getAttachments(searchRequest);
|
1243
|
-
};
|
1244
|
-
DocumentTemplatesApiService.prototype.getAttachmentFile = function (id) {
|
1245
|
-
return this.documentAttachmentService.getAttachmentFile(id);
|
1246
|
-
};
|
1247
|
-
DocumentTemplatesApiService.prototype.createAttachment = function (attachment, file, reportProgress) {
|
1248
|
-
return this.documentAttachmentService.createAttachment(attachment, file, reportProgress);
|
1249
|
-
};
|
1250
|
-
DocumentTemplatesApiService.prototype.removeAttachment = function (id) {
|
1251
|
-
return this.documentAttachmentService.removeAttachment(id);
|
1252
|
-
};
|
1253
|
-
DocumentTemplatesApiService.prototype.downloadTemplateFile = function (id) {
|
1254
|
-
var _this = this;
|
1255
|
-
return this.service
|
1256
|
-
.api({
|
1257
|
-
url: "/templates/" + id + "/file",
|
1258
|
-
responseType: 'blob',
|
1259
|
-
observe: 'response',
|
1260
|
-
})
|
1261
|
-
.pipe(operators.tap(function (response) {
|
1262
|
-
_this.fileDownloadService.processDownload(response);
|
1263
|
-
}), operators.map(function (response) { return response.body || response; }));
|
1264
|
-
};
|
1265
|
-
DocumentTemplatesApiService.prototype.generateWithBackendDocxTemplater = function (_e) {
|
1266
|
-
var template = _e.template, quote = _e.quote, attachmentIds = _e.attachmentIds, params = _e.params;
|
1267
|
-
var shouldPreventDownload = params.shouldPreventDownload;
|
1268
|
-
var nonEmptyParams = Object.keys(params || {})
|
1269
|
-
.filter(function (k) { return params[k] !== undefined; })
|
1270
|
-
.reduce(function (obj, key) {
|
1271
|
-
obj[key] = params[key];
|
1272
|
-
return obj;
|
1273
|
-
}, {});
|
1274
|
-
return this.generate("/templates/" + template.id + "/generate", { quote: quote, attachments: attachmentIds }, Boolean(shouldPreventDownload), 'blob', nonEmptyParams, false);
|
1275
|
-
};
|
1276
|
-
DocumentTemplatesApiService.prototype.generate = function (url, body, shouldPreventDownload, responseType, params, isUpload, reportProgress) {
|
1277
|
-
var _this = this;
|
1278
|
-
var requestOptions = {
|
1279
|
-
method: 'post',
|
1280
|
-
url: url,
|
1281
|
-
body: body,
|
1282
|
-
reportProgress: reportProgress,
|
1283
|
-
responseType: responseType,
|
1284
|
-
observe: shouldPreventDownload ? 'body' : 'response',
|
1285
|
-
params: params,
|
1286
|
-
};
|
1287
|
-
return (isUpload ? this.service.upload(requestOptions) : this.service.api(requestOptions)).pipe(operators.tap(function (response) {
|
1288
|
-
if (!shouldPreventDownload) {
|
1289
|
-
_this.fileDownloadService.processDownload(response);
|
1290
|
-
}
|
1291
|
-
}));
|
1320
|
+
}).filter(Boolean)) !== null && _b !== void 0 ? _b : [];
|
1321
|
+
if (!attachmentIds.length) {
|
1322
|
+
return rxjs.of([]);
|
1323
|
+
}
|
1324
|
+
return rxjs.forkJoin(attachmentIds.map(function (id) { return _this.documentAttachmentService.getAttachmentFile(id, true); }));
|
1292
1325
|
};
|
1293
|
-
DocumentTemplatesApiService.prototype.queryObject = function (
|
1294
|
-
var objectName =
|
1295
|
-
var properties =
|
1326
|
+
DocumentTemplatesApiService.prototype.queryObject = function (_g, _h) {
|
1327
|
+
var objectName = _g.objectName, resultObjectName = _g.resultObjectName, fields = _g.fields, statement = _g.statement;
|
1328
|
+
var properties = _h.properties;
|
1296
1329
|
var _a;
|
1297
1330
|
var patternLimit = /(\s*limit\s\d*)/i;
|
1298
1331
|
var limit = 1;
|
@@ -1305,18 +1338,18 @@
|
|
1305
1338
|
}
|
1306
1339
|
var resolvedStatement = i1.StringUtils.fillPlaceholders(statement, properties, /:\s*(\w[\w\d_.]+)/i);
|
1307
1340
|
var searchRequest = Object.assign({ skip: 0, count: limit, rawCondition: resolvedStatement }, ((fields === null || fields === void 0 ? void 0 : fields.length) && !!fields[0] && { fields: fields }));
|
1308
|
-
return this.
|
1309
|
-
var
|
1310
|
-
return (
|
1341
|
+
return this.salesforceApiService.query(searchRequest, objectName).pipe(this.mapSfQueryResult(limit), operators.map(function (value) {
|
1342
|
+
var _g;
|
1343
|
+
return (_g = {}, _g[resultObjectName] = value, _g);
|
1311
1344
|
}));
|
1312
1345
|
};
|
1313
1346
|
return DocumentTemplatesApiService;
|
1314
1347
|
}());
|
1315
|
-
DocumentTemplatesApiService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentTemplatesApiService, deps: [{ token: i1__namespace.BaseHttpService }, { token: SalesforceApiService }, { token: i1__namespace.FileDownloadService }, { token: DocumentAttachmentApiService }, { token:
|
1348
|
+
DocumentTemplatesApiService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentTemplatesApiService, deps: [{ token: i1__namespace.BaseHttpService }, { token: SalesforceApiService }, { token: i1__namespace.FileDownloadService }, { token: DocumentAttachmentApiService }, { token: QuoteApiService }, { token: i5__namespace.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1316
1349
|
DocumentTemplatesApiService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentTemplatesApiService });
|
1317
1350
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentTemplatesApiService, decorators: [{
|
1318
1351
|
type: i0.Injectable
|
1319
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.BaseHttpService }, { type: SalesforceApiService }, { type: i1__namespace.FileDownloadService }, { type: DocumentAttachmentApiService }, { type:
|
1352
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.BaseHttpService }, { type: SalesforceApiService }, { type: i1__namespace.FileDownloadService }, { type: DocumentAttachmentApiService }, { type: QuoteApiService }, { type: i5__namespace.HttpClient }]; } });
|
1320
1353
|
|
1321
1354
|
var PriceApiService = /** @class */ (function () {
|
1322
1355
|
function PriceApiService(httpService) {
|
@@ -1411,7 +1444,7 @@
|
|
1411
1444
|
return _this.searchProcedures$(new i1.Expression(), 0, 100);
|
1412
1445
|
};
|
1413
1446
|
this.searchProcedures$ = function (expression, skip, count) {
|
1414
|
-
var params = new
|
1447
|
+
var params = new i5.HttpParams();
|
1415
1448
|
params = params.set('skip', '' + skip);
|
1416
1449
|
params = params.set('count', '' + count);
|
1417
1450
|
return _this.baseHttpService.api({ method: 'post', url: _this.serviceUrl + "/search", params: params, body: expression });
|
@@ -1696,40 +1729,6 @@
|
|
1696
1729
|
type: i0.Injectable
|
1697
1730
|
}], ctorParameters: function () { return [{ type: i1__namespace.BaseHttpService }]; } });
|
1698
1731
|
|
1699
|
-
var QuoteApiService = /** @class */ (function () {
|
1700
|
-
function QuoteApiService(httpService) {
|
1701
|
-
this.httpService = httpService;
|
1702
|
-
this.SERVICE_URL = '/quotes';
|
1703
|
-
}
|
1704
|
-
QuoteApiService.prototype.getQuote = function (quoteId, params) {
|
1705
|
-
return this.httpService.api({
|
1706
|
-
method: 'get',
|
1707
|
-
url: this.SERVICE_URL + "/" + quoteId,
|
1708
|
-
params: params,
|
1709
|
-
});
|
1710
|
-
};
|
1711
|
-
QuoteApiService.prototype.upsertQuote = function (request) {
|
1712
|
-
return this.httpService.api({
|
1713
|
-
method: 'post',
|
1714
|
-
url: "" + this.SERVICE_URL,
|
1715
|
-
body: request,
|
1716
|
-
});
|
1717
|
-
};
|
1718
|
-
QuoteApiService.prototype.submitQuote = function (request) {
|
1719
|
-
return this.httpService.api({
|
1720
|
-
method: 'post',
|
1721
|
-
url: this.SERVICE_URL + "/submit",
|
1722
|
-
body: request,
|
1723
|
-
});
|
1724
|
-
};
|
1725
|
-
return QuoteApiService;
|
1726
|
-
}());
|
1727
|
-
QuoteApiService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteApiService, deps: [{ token: i1__namespace.BaseHttpService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1728
|
-
QuoteApiService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteApiService });
|
1729
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteApiService, decorators: [{
|
1730
|
-
type: i0.Injectable
|
1731
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.BaseHttpService }]; } });
|
1732
|
-
|
1733
1732
|
var RampApiService = /** @class */ (function () {
|
1734
1733
|
function RampApiService(httpService) {
|
1735
1734
|
this.httpService = httpService;
|
@@ -1779,7 +1778,7 @@
|
|
1779
1778
|
return _this.searchRuleGroups$(new i1.Expression(), 0, 100);
|
1780
1779
|
};
|
1781
1780
|
this.searchRuleGroups$ = function (expression, skip, count) {
|
1782
|
-
var params = new
|
1781
|
+
var params = new i5.HttpParams();
|
1783
1782
|
params = params.set('skip', '' + skip);
|
1784
1783
|
params = params.set('count', '' + count);
|
1785
1784
|
return _this.baseHttpService.api({ method: 'post', url: _this.serviceUrl + "/search", params: params, body: expression });
|
@@ -1809,7 +1808,7 @@
|
|
1809
1808
|
return _this.searchRules$(new i1.Expression(), 0, 100);
|
1810
1809
|
};
|
1811
1810
|
this.searchRules$ = function (expression, skip, count) {
|
1812
|
-
var params = new
|
1811
|
+
var params = new i5.HttpParams();
|
1813
1812
|
params = params.set('skip', '' + skip);
|
1814
1813
|
params = params.set('count', '' + count);
|
1815
1814
|
return _this.baseHttpService.api({ method: 'post', url: _this.serviceUrl + "/search", params: params, body: expression });
|
@@ -1873,7 +1872,7 @@
|
|
1873
1872
|
return _this.baseHttpService.api({ url: "" + _this.serviceUrl });
|
1874
1873
|
};
|
1875
1874
|
this.searchScripts$ = function (expression, skip, count) {
|
1876
|
-
var params = new
|
1875
|
+
var params = new i5.HttpParams();
|
1877
1876
|
params = params.set('skip', '' + skip);
|
1878
1877
|
params = params.set('count', '' + count);
|
1879
1878
|
return _this.baseHttpService.api({ method: 'post', url: _this.serviceUrl + "/search", params: params, body: expression });
|
@@ -1957,7 +1956,7 @@
|
|
1957
1956
|
this.baseHttpService = baseHttpService;
|
1958
1957
|
this.serviceUrl = '/uitemplates';
|
1959
1958
|
this.fetchTemplates$ = function (name) {
|
1960
|
-
var params = new
|
1959
|
+
var params = new i5.HttpParams();
|
1961
1960
|
if (name) {
|
1962
1961
|
params = params.append('name', name);
|
1963
1962
|
}
|
@@ -2007,7 +2006,7 @@
|
|
2007
2006
|
});
|
2008
2007
|
};
|
2009
2008
|
this.fetchComponents$ = function (templateId, name) {
|
2010
|
-
var params = new
|
2009
|
+
var params = new i5.HttpParams();
|
2011
2010
|
if (name) {
|
2012
2011
|
params = params.append('name', name);
|
2013
2012
|
}
|
@@ -2085,7 +2084,7 @@
|
|
2085
2084
|
}), rxjs.map(function (attachments) { return fromUIComponentStoryDTO(storyDto, attachments); }));
|
2086
2085
|
};
|
2087
2086
|
this.fetchStories$ = function (templateId, componentId, name) {
|
2088
|
-
var params = new
|
2087
|
+
var params = new i5.HttpParams();
|
2089
2088
|
if (name) {
|
2090
2089
|
params = params.append('name', name);
|
2091
2090
|
}
|
@@ -2240,7 +2239,7 @@
|
|
2240
2239
|
return ApiModule;
|
2241
2240
|
}());
|
2242
2241
|
ApiModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ApiModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
2243
|
-
ApiModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ApiModule, imports: [
|
2242
|
+
ApiModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ApiModule, imports: [i5.HttpClientModule] });
|
2244
2243
|
ApiModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ApiModule, providers: [
|
2245
2244
|
i1.BaseHttpService,
|
2246
2245
|
i1.XrayService,
|
@@ -2259,11 +2258,11 @@
|
|
2259
2258
|
ScriptsApiService,
|
2260
2259
|
RulesApiService,
|
2261
2260
|
RuleGroupsApiService,
|
2262
|
-
], imports: [[
|
2261
|
+
], imports: [[i5.HttpClientModule]] });
|
2263
2262
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ApiModule, decorators: [{
|
2264
2263
|
type: i0.NgModule,
|
2265
2264
|
args: [{
|
2266
|
-
imports: [
|
2265
|
+
imports: [i5.HttpClientModule],
|
2267
2266
|
providers: [
|
2268
2267
|
i1.BaseHttpService,
|
2269
2268
|
i1.XrayService,
|