@veloceapps/api 1.0.0

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.
Files changed (62) hide show
  1. package/README.md +7 -0
  2. package/bundles/veloce-api.umd.js +2117 -0
  3. package/bundles/veloce-api.umd.js.map +1 -0
  4. package/esm2015/index.js +14 -0
  5. package/esm2015/lib/api.module.js +59 -0
  6. package/esm2015/lib/services/configuration-api.service.js +90 -0
  7. package/esm2015/lib/services/configuration-settings-api.service.js +69 -0
  8. package/esm2015/lib/services/context-api.service.js +26 -0
  9. package/esm2015/lib/services/document-attachment-api.service.js +65 -0
  10. package/esm2015/lib/services/document-templates-api.service.js +278 -0
  11. package/esm2015/lib/services/price-api.service.js +86 -0
  12. package/esm2015/lib/services/product-model-api.service.js +232 -0
  13. package/esm2015/lib/services/quote-api.service.js +36 -0
  14. package/esm2015/lib/services/ramp-api.service.js +42 -0
  15. package/esm2015/lib/services/salesforce-api.service.js +51 -0
  16. package/esm2015/lib/services/scripts-api.service.js +75 -0
  17. package/esm2015/lib/services/ui-templates-api.service.js +262 -0
  18. package/esm2015/lib/types/attribute-dto.types.js +21 -0
  19. package/esm2015/lib/types/charge-group-item-dto.types.js +45 -0
  20. package/esm2015/lib/types/charge-item-dto.types.js +74 -0
  21. package/esm2015/lib/types/clone-request.types.js +2 -0
  22. package/esm2015/lib/types/configuration-settings-dto.types.js +22 -0
  23. package/esm2015/lib/types/domain-type-dto.types.js +27 -0
  24. package/esm2015/lib/types/line-item-dto.types.js +93 -0
  25. package/esm2015/lib/types/port-domain-dto.types.js +22 -0
  26. package/esm2015/lib/types/price-adjustment-dto.types.js +15 -0
  27. package/esm2015/lib/types/price-dto.types.js +25 -0
  28. package/esm2015/lib/types/recommended-price-dto.types.js +23 -0
  29. package/esm2015/lib/types/ui-template-dto.types.js +2 -0
  30. package/esm2015/lib/utils/ui-template.utils.js +17 -0
  31. package/esm2015/veloce-api.js +5 -0
  32. package/fesm2015/veloce-api.js +1686 -0
  33. package/fesm2015/veloce-api.js.map +1 -0
  34. package/index.d.ts +14 -0
  35. package/lib/api.module.d.ts +7 -0
  36. package/lib/services/configuration-api.service.d.ts +18 -0
  37. package/lib/services/configuration-settings-api.service.d.ts +17 -0
  38. package/lib/services/context-api.service.d.ts +11 -0
  39. package/lib/services/document-attachment-api.service.d.ts +15 -0
  40. package/lib/services/document-templates-api.service.d.ts +39 -0
  41. package/lib/services/price-api.service.d.ts +16 -0
  42. package/lib/services/product-model-api.service.d.ts +30 -0
  43. package/lib/services/quote-api.service.d.ts +14 -0
  44. package/lib/services/ramp-api.service.d.ts +12 -0
  45. package/lib/services/salesforce-api.service.d.ts +17 -0
  46. package/lib/services/scripts-api.service.d.ts +21 -0
  47. package/lib/services/ui-templates-api.service.d.ts +47 -0
  48. package/lib/types/attribute-dto.types.d.ts +11 -0
  49. package/lib/types/charge-group-item-dto.types.d.ts +24 -0
  50. package/lib/types/charge-item-dto.types.d.ts +39 -0
  51. package/lib/types/clone-request.types.d.ts +6 -0
  52. package/lib/types/configuration-settings-dto.types.d.ts +9 -0
  53. package/lib/types/domain-type-dto.types.d.ts +15 -0
  54. package/lib/types/line-item-dto.types.d.ts +50 -0
  55. package/lib/types/port-domain-dto.types.d.ts +13 -0
  56. package/lib/types/price-adjustment-dto.types.d.ts +8 -0
  57. package/lib/types/price-dto.types.d.ts +13 -0
  58. package/lib/types/recommended-price-dto.types.d.ts +12 -0
  59. package/lib/types/ui-template-dto.types.d.ts +10 -0
  60. package/lib/utils/ui-template.utils.d.ts +3 -0
  61. package/package.json +33 -0
  62. package/veloce-api.d.ts +5 -0
@@ -0,0 +1,1686 @@
1
+ import * as i4 from '@angular/common/http';
2
+ import { HttpParams, HttpClientModule } from '@angular/common/http';
3
+ import * as i0 from '@angular/core';
4
+ import { Injectable, NgModule } from '@angular/core';
5
+ import * as i1 from '@veloce/core';
6
+ import { ModelTranslatorUtils, ConfigurationContextMode, QuoteDraft, DocxTemplater, StringUtils, ProductModelsContainer, ModelUtils, EntityUtil, UUID, BaseHttpService, XrayService } from '@veloce/core';
7
+ import { throwError, forkJoin, zip, of, catchError as catchError$1, map as map$1, switchMap as switchMap$1 } from 'rxjs';
8
+ import { map, tap, defaultIfEmpty, switchMap, catchError } from 'rxjs/operators';
9
+ import * as _ from 'lodash';
10
+ import { transform } from 'lodash';
11
+ import { CurrencyPipe } from '@angular/common';
12
+ import * as moment_ from 'moment';
13
+ import { __rest } from 'tslib';
14
+
15
+ class AttributeDTO {
16
+ constructor(name, type, value, cfgStatus, id, scale) {
17
+ this.name = name;
18
+ this.type = type;
19
+ this.value = value;
20
+ this.cfgStatus = cfgStatus;
21
+ this.id = id;
22
+ this.scale = scale;
23
+ }
24
+ static fromDTO(dto) {
25
+ return {
26
+ id: dto.id,
27
+ name: dto.name,
28
+ type: dto.type,
29
+ scale: dto.scale,
30
+ value: dto.value,
31
+ cfgStatus: dto.cfgStatus,
32
+ };
33
+ }
34
+ }
35
+
36
+ class PriceAdjustmentDTO {
37
+ constructor(amount, explanation, type) {
38
+ this.amount = amount;
39
+ this.explanation = explanation;
40
+ this.type = type;
41
+ }
42
+ static fromDTO(dto) {
43
+ return {
44
+ amount: dto.amount,
45
+ explanation: dto.explanation,
46
+ type: dto.type,
47
+ };
48
+ }
49
+ }
50
+
51
+ class ChargeGroupItemDTO {
52
+ constructor(chargeType, chargeMethod, properties, id, chargeTypeDisplayValue, frequencyUnit, frequencyDuration, currency, sellingTerm, netPrice, listPrice, netUnitPrice, listUnitPrice, cost, priceAdjustment, priceWaterfalls, enablePriceAdjustment) {
53
+ this.chargeType = chargeType;
54
+ this.chargeMethod = chargeMethod;
55
+ this.properties = properties;
56
+ this.id = id;
57
+ this.chargeTypeDisplayValue = chargeTypeDisplayValue;
58
+ this.frequencyUnit = frequencyUnit;
59
+ this.frequencyDuration = frequencyDuration;
60
+ this.currency = currency;
61
+ this.sellingTerm = sellingTerm;
62
+ this.netPrice = netPrice;
63
+ this.listPrice = listPrice;
64
+ this.netUnitPrice = netUnitPrice;
65
+ this.listUnitPrice = listUnitPrice;
66
+ this.cost = cost;
67
+ this.priceAdjustment = priceAdjustment;
68
+ this.priceWaterfalls = priceWaterfalls;
69
+ this.enablePriceAdjustment = enablePriceAdjustment;
70
+ }
71
+ static fromDTO(dto) {
72
+ var _a;
73
+ return {
74
+ id: dto.id,
75
+ chargeType: dto.chargeType,
76
+ chargeTypeDisplayValue: dto.chargeTypeDisplayValue,
77
+ chargeMethod: dto.chargeMethod,
78
+ frequencyUnit: dto.frequencyUnit,
79
+ frequencyDuration: dto.frequencyDuration,
80
+ currency: dto.currency,
81
+ sellingTerm: dto.sellingTerm,
82
+ netPrice: dto.netPrice,
83
+ listPrice: dto.listPrice,
84
+ netUnitPrice: dto.netUnitPrice,
85
+ listUnitPrice: dto.listUnitPrice,
86
+ cost: dto.cost,
87
+ priceAdjustment: dto.priceAdjustment && PriceAdjustmentDTO.fromDTO(dto.priceAdjustment),
88
+ priceWaterfalls: (_a = dto.priceWaterfalls) === null || _a === void 0 ? void 0 : _a.map(PriceAdjustmentDTO.fromDTO),
89
+ enablePriceAdjustment: dto.enablePriceAdjustment,
90
+ properties: dto.properties,
91
+ };
92
+ }
93
+ }
94
+
95
+ class ChargeItemDTO {
96
+ constructor(id, price, unitPrice, baseListPrice, baseListUnitPrice, listPrice, listUnitPrice, netPrice, netUnitPrice, chargeId, chargeType, chargeMethod, priceItemId, startDate, priceWaterfalls, quantity, properties, chargeTypeDisplayValue, arr, frequencyUnit, frequencyDuration, endDate, sellingTerm, currency, unitCost, cost, minUnitPrice, minPrice, enablePriceAdjustment, enableListPriceAdjustment, listPriceAdjustment, priceAdjustment) {
97
+ this.id = id;
98
+ this.price = price;
99
+ this.unitPrice = unitPrice;
100
+ this.baseListPrice = baseListPrice;
101
+ this.baseListUnitPrice = baseListUnitPrice;
102
+ this.listPrice = listPrice;
103
+ this.listUnitPrice = listUnitPrice;
104
+ this.netPrice = netPrice;
105
+ this.netUnitPrice = netUnitPrice;
106
+ this.chargeId = chargeId;
107
+ this.chargeType = chargeType;
108
+ this.chargeMethod = chargeMethod;
109
+ this.priceItemId = priceItemId;
110
+ this.startDate = startDate;
111
+ this.priceWaterfalls = priceWaterfalls;
112
+ this.quantity = quantity;
113
+ this.properties = properties;
114
+ this.chargeTypeDisplayValue = chargeTypeDisplayValue;
115
+ this.arr = arr;
116
+ this.frequencyUnit = frequencyUnit;
117
+ this.frequencyDuration = frequencyDuration;
118
+ this.endDate = endDate;
119
+ this.sellingTerm = sellingTerm;
120
+ this.currency = currency;
121
+ this.unitCost = unitCost;
122
+ this.cost = cost;
123
+ this.minUnitPrice = minUnitPrice;
124
+ this.minPrice = minPrice;
125
+ this.enablePriceAdjustment = enablePriceAdjustment;
126
+ this.enableListPriceAdjustment = enableListPriceAdjustment;
127
+ this.listPriceAdjustment = listPriceAdjustment;
128
+ this.priceAdjustment = priceAdjustment;
129
+ }
130
+ static fromDTO(dto) {
131
+ return {
132
+ id: dto.id,
133
+ price: dto.price,
134
+ unitPrice: dto.unitPrice,
135
+ baseListPrice: dto.baseListPrice,
136
+ baseListUnitPrice: dto.baseListUnitPrice,
137
+ listPrice: dto.listPrice,
138
+ listUnitPrice: dto.listUnitPrice,
139
+ netPrice: dto.netPrice,
140
+ netUnitPrice: dto.netUnitPrice,
141
+ chargeId: dto.chargeId,
142
+ chargeType: dto.chargeType,
143
+ chargeTypeDisplayValue: dto.chargeTypeDisplayValue,
144
+ chargeMethod: dto.chargeMethod,
145
+ priceItemId: dto.priceItemId,
146
+ startDate: dto.startDate,
147
+ endDate: dto.endDate,
148
+ priceWaterfalls: dto.priceWaterfalls.map(PriceAdjustmentDTO.fromDTO),
149
+ quantity: dto.quantity,
150
+ properties: dto.properties,
151
+ arr: dto.arr,
152
+ frequencyUnit: dto.frequencyUnit,
153
+ frequencyDuration: dto.frequencyDuration,
154
+ sellingTerm: dto.sellingTerm,
155
+ currency: dto.currency,
156
+ unitCost: dto.unitCost,
157
+ cost: dto.cost,
158
+ minUnitPrice: dto.minUnitPrice,
159
+ minPrice: dto.minPrice,
160
+ enablePriceAdjustment: dto.enablePriceAdjustment,
161
+ enableListPriceAdjustment: dto.enableListPriceAdjustment,
162
+ listPriceAdjustment: dto.listPriceAdjustment && PriceAdjustmentDTO.fromDTO(dto.listPriceAdjustment),
163
+ priceAdjustment: dto.priceAdjustment && PriceAdjustmentDTO.fromDTO(dto.priceAdjustment),
164
+ };
165
+ }
166
+ }
167
+
168
+ class RecommendedPriceDTO {
169
+ constructor(netPrice, listPrice, chargeType, chargeMethod, explanation, frequencyDuration, frequencyUnit) {
170
+ this.netPrice = netPrice;
171
+ this.listPrice = listPrice;
172
+ this.chargeType = chargeType;
173
+ this.chargeMethod = chargeMethod;
174
+ this.explanation = explanation;
175
+ this.frequencyDuration = frequencyDuration;
176
+ this.frequencyUnit = frequencyUnit;
177
+ }
178
+ static fromDTO(dto) {
179
+ return {
180
+ netPrice: dto.netPrice,
181
+ listPrice: dto.listPrice,
182
+ chargeType: dto.chargeType,
183
+ chargeMethod: dto.chargeMethod,
184
+ frequencyUnit: dto.frequencyUnit,
185
+ frequencyDuration: dto.frequencyDuration,
186
+ explanation: dto.explanation,
187
+ };
188
+ }
189
+ }
190
+
191
+ class DomainTypeDTO {
192
+ constructor(name, displayName, minCard, maxCard, recommendedPrices, properties, status, cardinality) {
193
+ this.name = name;
194
+ this.displayName = displayName;
195
+ this.minCard = minCard;
196
+ this.maxCard = maxCard;
197
+ this.recommendedPrices = recommendedPrices;
198
+ this.properties = properties;
199
+ this.status = status;
200
+ this.cardinality = cardinality;
201
+ }
202
+ static fromDTO(dto) {
203
+ var _a;
204
+ return {
205
+ name: dto.name,
206
+ displayName: dto.displayName,
207
+ minCard: dto.minCard,
208
+ maxCard: dto.maxCard,
209
+ recommendedPrices: (_a = dto.recommendedPrices) === null || _a === void 0 ? void 0 : _a.map(RecommendedPriceDTO.fromDTO),
210
+ properties: dto.properties,
211
+ status: dto.status,
212
+ cardinality: dto.cardinality,
213
+ };
214
+ }
215
+ }
216
+
217
+ class PortDomainDTO {
218
+ constructor(name, type, minCard, maxCard, domainTypes, properties) {
219
+ this.name = name;
220
+ this.type = type;
221
+ this.minCard = minCard;
222
+ this.maxCard = maxCard;
223
+ this.domainTypes = domainTypes;
224
+ this.properties = properties;
225
+ }
226
+ static fromDTO(dto) {
227
+ return {
228
+ name: dto.name,
229
+ type: dto.type,
230
+ minCard: dto.minCard,
231
+ maxCard: dto.maxCard,
232
+ domainTypes: dto.domainTypes.map(DomainTypeDTO.fromDTO),
233
+ properties: dto.properties,
234
+ };
235
+ }
236
+ }
237
+
238
+ class PriceDTO {
239
+ constructor(netPrice, listPrice, chargeType, chargeTypeDisplayValue, chargeMethod, frequencyUnit, frequencyDuration, sellingTerm) {
240
+ this.netPrice = netPrice;
241
+ this.listPrice = listPrice;
242
+ this.chargeType = chargeType;
243
+ this.chargeTypeDisplayValue = chargeTypeDisplayValue;
244
+ this.chargeMethod = chargeMethod;
245
+ this.frequencyUnit = frequencyUnit;
246
+ this.frequencyDuration = frequencyDuration;
247
+ this.sellingTerm = sellingTerm;
248
+ }
249
+ static fromDTO(dto) {
250
+ return {
251
+ netPrice: dto.netPrice,
252
+ listPrice: dto.listPrice,
253
+ chargeType: dto.chargeType,
254
+ chargeTypeDisplayValue: dto.chargeTypeDisplayValue,
255
+ chargeMethod: dto.chargeMethod,
256
+ frequencyUnit: dto.frequencyUnit,
257
+ frequencyDuration: dto.frequencyDuration,
258
+ sellingTerm: dto.sellingTerm,
259
+ };
260
+ }
261
+ }
262
+
263
+ class LineItemDTO {
264
+ constructor(id, activated, attributes, attributeDomains, cfgStatus, chargeGroupItems, chargeItems, domainComputations, lineItems, messages, name, optionalCharges, pending, portDomains, properties, qty, totalPrices, type, productId, port, parentId, assetId, openOrderLineItemId, productName, rootId, actionCode, serviceStartDate, effectiveDate, startDate, endDate, planId, sellingFrequencyUnit, sellingFrequencyDuration, offeringId, offeringItemId, offeringInstanceId, rampInstanceId, enableRamp, configurable) {
265
+ this.id = id;
266
+ this.activated = activated;
267
+ this.attributes = attributes;
268
+ this.attributeDomains = attributeDomains;
269
+ this.cfgStatus = cfgStatus;
270
+ this.chargeGroupItems = chargeGroupItems;
271
+ this.chargeItems = chargeItems;
272
+ this.domainComputations = domainComputations;
273
+ this.lineItems = lineItems;
274
+ this.messages = messages;
275
+ this.name = name;
276
+ this.optionalCharges = optionalCharges;
277
+ this.pending = pending;
278
+ this.portDomains = portDomains;
279
+ this.properties = properties;
280
+ this.qty = qty;
281
+ this.totalPrices = totalPrices;
282
+ this.type = type;
283
+ this.productId = productId;
284
+ this.port = port;
285
+ this.parentId = parentId;
286
+ this.assetId = assetId;
287
+ this.openOrderLineItemId = openOrderLineItemId;
288
+ this.productName = productName;
289
+ this.rootId = rootId;
290
+ this.actionCode = actionCode;
291
+ this.serviceStartDate = serviceStartDate;
292
+ this.effectiveDate = effectiveDate;
293
+ this.startDate = startDate;
294
+ this.endDate = endDate;
295
+ this.planId = planId;
296
+ this.sellingFrequencyUnit = sellingFrequencyUnit;
297
+ this.sellingFrequencyDuration = sellingFrequencyDuration;
298
+ this.offeringId = offeringId;
299
+ this.offeringItemId = offeringItemId;
300
+ this.offeringInstanceId = offeringInstanceId;
301
+ this.rampInstanceId = rampInstanceId;
302
+ this.enableRamp = enableRamp;
303
+ this.configurable = configurable;
304
+ }
305
+ static fromDTO(dto) {
306
+ return {
307
+ id: dto.id,
308
+ activated: dto.activated,
309
+ attributes: dto.attributes.map(AttributeDTO.fromDTO),
310
+ attributeDomains: dto.attributeDomains,
311
+ cfgStatus: dto.cfgStatus,
312
+ chargeGroupItems: dto.chargeGroupItems.map(ChargeGroupItemDTO.fromDTO),
313
+ chargeItems: dto.chargeItems.map(ChargeItemDTO.fromDTO),
314
+ domainComputations: dto.domainComputations,
315
+ lineItems: dto.lineItems.map(LineItemDTO.fromDTO),
316
+ messages: dto.messages,
317
+ name: dto.name,
318
+ optionalCharges: dto.optionalCharges,
319
+ pending: dto.pending,
320
+ portDomains: transform(dto.portDomains, (result, value, key) => (result[key] = PortDomainDTO.fromDTO(value))),
321
+ properties: dto.properties,
322
+ qty: dto.qty,
323
+ totalPrices: transform(dto.totalPrices, (result, value, key) => (result[key] = PriceDTO.fromDTO(value))),
324
+ type: dto.type,
325
+ productId: dto.productId,
326
+ port: dto.port,
327
+ parentId: dto.parentId,
328
+ assetId: dto.assetId,
329
+ openOrderLineItemId: dto.openOrderLineItemId,
330
+ productName: dto.productName,
331
+ rootId: dto.rootId,
332
+ actionCode: dto.actionCode,
333
+ serviceStartDate: dto.serviceStartDate,
334
+ effectiveDate: dto.effectiveDate,
335
+ startDate: dto.startDate,
336
+ endDate: dto.endDate,
337
+ planId: dto.planId,
338
+ sellingFrequencyUnit: dto.sellingFrequencyUnit,
339
+ sellingFrequencyDuration: dto.sellingFrequencyDuration,
340
+ offeringId: dto.offeringId,
341
+ offeringItemId: dto.offeringItemId,
342
+ offeringInstanceId: dto.offeringInstanceId,
343
+ rampInstanceId: dto.rampInstanceId,
344
+ enableRamp: dto.enableRamp,
345
+ configurable: dto.configurable,
346
+ };
347
+ }
348
+ }
349
+
350
+ class ConfigurationApiService {
351
+ constructor(httpService) {
352
+ this.httpService = httpService;
353
+ this.SERVICE_URL = '/configuration';
354
+ }
355
+ configureLineItem(configurationRequest, runtimeModel) {
356
+ return this.httpService
357
+ .api({
358
+ method: 'post',
359
+ url: `${this.SERVICE_URL}`,
360
+ body: configurationRequest,
361
+ errorHandler: e => throwError(e),
362
+ })
363
+ .pipe(map(response => {
364
+ const lineItem = LineItemDTO.fromDTO(response);
365
+ if (runtimeModel) {
366
+ return this.updatePortDomains(lineItem, runtimeModel);
367
+ }
368
+ else {
369
+ return lineItem;
370
+ }
371
+ }));
372
+ }
373
+ configureAndPriceLineItem(configurationRequest, runtimeModel) {
374
+ return this.httpService
375
+ .api({
376
+ method: 'post',
377
+ url: `${this.SERVICE_URL}/price`,
378
+ body: configurationRequest,
379
+ errorHandler: e => throwError(e),
380
+ })
381
+ .pipe(map(response => {
382
+ const lineItem = LineItemDTO.fromDTO(response.lineItem);
383
+ return {
384
+ lineItem: this.updatePortDomains(lineItem, runtimeModel),
385
+ context: response.context,
386
+ };
387
+ }));
388
+ }
389
+ getRuntimeDataByProductId(productId, offeringId) {
390
+ return this.httpService
391
+ .api({
392
+ method: 'get',
393
+ url: `${this.SERVICE_URL}/${productId}/model` + ((offeringId && `/${offeringId}`) || ''),
394
+ })
395
+ .pipe(map(runtimeData => {
396
+ runtimeData.uiDefinitions = JSON.parse(runtimeData.uiDefinitionsSource);
397
+ runtimeData.uiDefinitions.forEach(uiDefinition => {
398
+ ModelTranslatorUtils.toLocalUIDefinition(uiDefinition);
399
+ });
400
+ return runtimeData;
401
+ }));
402
+ }
403
+ getRuntimeDataByModelId(modelId) {
404
+ return this.httpService
405
+ .api({
406
+ method: 'get',
407
+ url: `${this.SERVICE_URL}/${modelId}/model-test`,
408
+ })
409
+ .pipe(map((runtimeData) => {
410
+ runtimeData.uiDefinitions = [];
411
+ return runtimeData;
412
+ }));
413
+ }
414
+ updatePortDomains(lineItem, runtimeModel) {
415
+ var _a, _b, _c;
416
+ const type = runtimeModel.components.get(lineItem.type);
417
+ const portDomains = Object.assign({}, lineItem.portDomains);
418
+ for (const port of (_a = type === null || type === void 0 ? void 0 : type.ports) !== null && _a !== void 0 ? _a : []) {
419
+ const portDomain = portDomains[port.name];
420
+ if (((_b = portDomain === null || portDomain === void 0 ? void 0 : portDomain.properties) === null || _b === void 0 ? void 0 : _b.domainComputation) === 'false') {
421
+ portDomain.domainTypes = port.domainTypes;
422
+ }
423
+ }
424
+ return Object.assign(Object.assign({}, lineItem), { lineItems: (_c = lineItem.lineItems) === null || _c === void 0 ? void 0 : _c.map(i => this.updatePortDomains(i, runtimeModel)), portDomains });
425
+ }
426
+ }
427
+ ConfigurationApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
428
+ ConfigurationApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationApiService });
429
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationApiService, decorators: [{
430
+ type: Injectable
431
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
432
+
433
+ class ConfigurationSettingsDTO {
434
+ constructor(id, key, value) {
435
+ this.id = id;
436
+ this.key = key;
437
+ this.value = value;
438
+ }
439
+ static fromDTO(dto, key) {
440
+ return {
441
+ id: dto === null || dto === void 0 ? void 0 : dto.id,
442
+ key: (dto === null || dto === void 0 ? void 0 : dto.key) || key || '',
443
+ value: dto === null || dto === void 0 ? void 0 : dto.value,
444
+ };
445
+ }
446
+ static toDTO(data) {
447
+ return {
448
+ id: data.id,
449
+ key: data.key,
450
+ value: data.value,
451
+ };
452
+ }
453
+ }
454
+
455
+ class ConfigurationSettingsApiService {
456
+ constructor(httpService) {
457
+ this.httpService = httpService;
458
+ this.SERVICE_URL = '/configuration-settings';
459
+ }
460
+ fetchSettings() {
461
+ return this.httpService
462
+ .api({
463
+ url: `${this.SERVICE_URL}`,
464
+ method: 'get',
465
+ })
466
+ .pipe(map((settings) => settings.map(setting => ConfigurationSettingsDTO.fromDTO(setting))));
467
+ }
468
+ fetchSetting(settingsKey) {
469
+ return this.httpService
470
+ .api({
471
+ url: `${this.SERVICE_URL}/byKey/${settingsKey}`,
472
+ method: 'get',
473
+ })
474
+ .pipe(map((setting) => ConfigurationSettingsDTO.fromDTO(setting, settingsKey)));
475
+ }
476
+ createSetting(setting) {
477
+ const request = ConfigurationSettingsDTO.toDTO(setting);
478
+ return this.httpService.api({
479
+ url: `${this.SERVICE_URL}`,
480
+ method: 'post',
481
+ body: Object.assign({}, request),
482
+ });
483
+ }
484
+ updateSetting(setting) {
485
+ const request = ConfigurationSettingsDTO.toDTO(setting);
486
+ return this.httpService.api({
487
+ url: `${this.SERVICE_URL}/${request.id}`,
488
+ method: 'put',
489
+ body: Object.assign({}, request),
490
+ });
491
+ }
492
+ removeSetting(setting) {
493
+ const request = ConfigurationSettingsDTO.toDTO(setting);
494
+ return this.httpService.api({
495
+ url: `${this.SERVICE_URL}/${request.id}`,
496
+ method: 'delete',
497
+ });
498
+ }
499
+ restoreSetting(settingId) {
500
+ return this.httpService.api({
501
+ url: `${this.SERVICE_URL}/${settingId}/restore`,
502
+ method: 'patch',
503
+ });
504
+ }
505
+ clear(name) {
506
+ return this.httpService
507
+ .api({
508
+ method: 'get',
509
+ url: '/cache/evict/' + name
510
+ });
511
+ }
512
+ }
513
+ ConfigurationSettingsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationSettingsApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
514
+ ConfigurationSettingsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationSettingsApiService });
515
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationSettingsApiService, decorators: [{
516
+ type: Injectable
517
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
518
+
519
+ class ContextApiService {
520
+ constructor(httpService) {
521
+ this.httpService = httpService;
522
+ this.SERVICE_URL = '/context';
523
+ }
524
+ getContext(headerId, mode) {
525
+ return this.httpService.api({
526
+ method: 'post',
527
+ body: {
528
+ headerId: headerId,
529
+ contextMode: ConfigurationContextMode[mode],
530
+ },
531
+ url: `${this.SERVICE_URL}`,
532
+ });
533
+ }
534
+ }
535
+ ContextApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ContextApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
536
+ ContextApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ContextApiService });
537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ContextApiService, decorators: [{
538
+ type: Injectable
539
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
540
+
541
+ class DocumentAttachmentApiService {
542
+ constructor(httpService, fileDownloadService) {
543
+ this.httpService = httpService;
544
+ this.fileDownloadService = fileDownloadService;
545
+ }
546
+ getAttachments(searchRequest) {
547
+ return this.httpService.api({
548
+ url: '/attachments/search',
549
+ method: 'post',
550
+ body: searchRequest,
551
+ });
552
+ }
553
+ createAttachment(attachment, file, reportProgress) {
554
+ const formData = new FormData();
555
+ if (file) {
556
+ formData.append('file', file, file.name);
557
+ }
558
+ formData.append('attachment', new Blob([JSON.stringify(attachment)], {
559
+ type: 'application/json',
560
+ }));
561
+ return this.httpService.upload({
562
+ url: `/attachments`,
563
+ body: formData,
564
+ method: 'post',
565
+ observe: reportProgress ? 'events' : undefined,
566
+ reportProgress,
567
+ });
568
+ }
569
+ updateAttachment(id, attachment) {
570
+ return this.httpService.api({
571
+ url: `/attachments/${id}`,
572
+ body: attachment,
573
+ method: 'put',
574
+ });
575
+ }
576
+ getAttachmentFile(id, isPreventDownload) {
577
+ return this.httpService
578
+ .api({
579
+ url: `/attachments/${id}/file`,
580
+ responseType: isPreventDownload ? 'arraybuffer' : 'blob',
581
+ observe: isPreventDownload ? 'body' : 'response',
582
+ })
583
+ .pipe(tap(response => {
584
+ if (!isPreventDownload) {
585
+ this.fileDownloadService.processDownload(response);
586
+ }
587
+ }), map(response => (isPreventDownload ? new Blob([response.body || response]) : response.body || response)));
588
+ }
589
+ removeAttachment(id) {
590
+ return this.httpService.api({
591
+ url: `/attachments/${id}`,
592
+ method: 'delete',
593
+ });
594
+ }
595
+ }
596
+ DocumentAttachmentApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentAttachmentApiService, deps: [{ token: i1.BaseHttpService }, { token: i1.FileDownloadService }], target: i0.ɵɵFactoryTarget.Injectable });
597
+ DocumentAttachmentApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentAttachmentApiService });
598
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentAttachmentApiService, decorators: [{
599
+ type: Injectable
600
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }, { type: i1.FileDownloadService }]; } });
601
+
602
+ class SalesforceApiService {
603
+ constructor(httpService) {
604
+ this.httpService = httpService;
605
+ this.SERVICE_URL = '/proxy';
606
+ }
607
+ query(searchRequest, objectName) {
608
+ return this.httpService.api({
609
+ method: 'post',
610
+ body: Object.assign(Object.assign({}, searchRequest), { count: searchRequest.count || 100 }),
611
+ url: `${this.SERVICE_URL}/query/${objectName}`,
612
+ });
613
+ }
614
+ queryObjects(search) {
615
+ const params = new HttpParams();
616
+ if (search) {
617
+ params.append('search', search);
618
+ }
619
+ return this.httpService.api({
620
+ url: `${this.SERVICE_URL}/query`,
621
+ params,
622
+ });
623
+ }
624
+ describe(objectName, fieldName) {
625
+ const methodUrl = `${this.SERVICE_URL}/describe/${objectName}/fields` + (fieldName ? `/${fieldName}` : '');
626
+ return this.httpService.api({ url: methodUrl });
627
+ }
628
+ describe2(objectName, fields) {
629
+ const methodUrl = `${this.SERVICE_URL}/describe/${objectName}/fields`;
630
+ return this.httpService.api({ method: 'post', url: methodUrl, body: fields });
631
+ }
632
+ apexGetRequest(path, params) {
633
+ return this.httpService.api({ url: `${this.SERVICE_URL}/apex${path}`, params });
634
+ }
635
+ apexPostRequest(path, body) {
636
+ return this.httpService.api({
637
+ method: 'post',
638
+ body,
639
+ url: `${this.SERVICE_URL}/apex${path}`,
640
+ });
641
+ }
642
+ }
643
+ SalesforceApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SalesforceApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
644
+ SalesforceApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SalesforceApiService });
645
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SalesforceApiService, decorators: [{
646
+ type: Injectable
647
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
648
+
649
+ const moment = moment_;
650
+ const mapSfQueryResult = (limit) => map((records) => {
651
+ if (!records.length) {
652
+ return { _result: 'No Records Found' };
653
+ }
654
+ if (limit === 1) {
655
+ return records[0];
656
+ }
657
+ return records;
658
+ });
659
+ const mapBooleanIfAplicable = (value) => {
660
+ if (value === 'true') {
661
+ return true;
662
+ }
663
+ if (value === 'false') {
664
+ return false;
665
+ }
666
+ return value;
667
+ };
668
+ class DocumentTemplatesApiService {
669
+ constructor(service, sfRepo, fileDownloadService, documentAttachmentService, http) {
670
+ this.service = service;
671
+ this.sfRepo = sfRepo;
672
+ this.fileDownloadService = fileDownloadService;
673
+ this.documentAttachmentService = documentAttachmentService;
674
+ this.http = http;
675
+ this.fallbackDocGenHost = 'https://dev-dp1.velocpq.com/docgen';
676
+ if (window.VELO_DOCGEN_API) {
677
+ this.docGenHost = window.VELO_DOCGEN_API;
678
+ }
679
+ else {
680
+ console.log(`window.VELO_DOCGEN_API not set, will use fallback "${this.fallbackDocGenHost}"`);
681
+ this.docGenHost = this.fallbackDocGenHost;
682
+ }
683
+ }
684
+ getTemplates(tag) {
685
+ return this.service.api({
686
+ url: '/templates',
687
+ method: 'get',
688
+ params: Object.assign({}, (tag && { tag })),
689
+ });
690
+ }
691
+ upsertTemplate(template, file, reportProgress) {
692
+ const formData = new FormData();
693
+ if (file) {
694
+ formData.append('file', file, file.name);
695
+ }
696
+ formData.append('template', new Blob([JSON.stringify(template)], {
697
+ type: 'application/json',
698
+ }));
699
+ return this.service.upload({
700
+ url: `/templates` + ((template.id && `/${template.id}`) || ''),
701
+ body: formData,
702
+ method: template.id ? 'put' : 'post',
703
+ reportProgress,
704
+ });
705
+ }
706
+ removeTemplate(id) {
707
+ return this.service.api({
708
+ url: '/templates' + id,
709
+ method: 'delete',
710
+ });
711
+ }
712
+ cloneTemplate(id) {
713
+ return this.service.api({
714
+ url: '/templates/clone/' + id,
715
+ method: 'post',
716
+ });
717
+ }
718
+ generateDocumentData(template, object, params) {
719
+ var _a, _b, _c, _d;
720
+ const shouldPreventDownload = params === null || params === void 0 ? void 0 : params.shouldPreventDownload;
721
+ const useLocalDataGeneration = (_b = (_a = template.properties) === null || _a === void 0 ? void 0 : _a.find(({ name }) => name === 'useLocalDataGeneration')) === null || _b === void 0 ? void 0 : _b.value;
722
+ if (!useLocalDataGeneration && object instanceof QuoteDraft) {
723
+ return this.generate('/templates/generate-data', { template, quote: object }, shouldPreventDownload, shouldPreventDownload ? 'json' : 'blob');
724
+ }
725
+ const allQueries = [...((_c = template === null || template === void 0 ? void 0 : template.queries) !== null && _c !== void 0 ? _c : [])];
726
+ const properties = ((_d = object === null || object === void 0 ? void 0 : object.context) === null || _d === void 0 ? void 0 : _d.properties) || (object === null || object === void 0 ? void 0 : object.properties) || {};
727
+ const accountId = properties === null || properties === void 0 ? void 0 : properties.AccountId;
728
+ const userId = properties === null || properties === void 0 ? void 0 : properties.UserId;
729
+ if (accountId) {
730
+ allQueries.push({
731
+ queryName: 'QuoteAccountQuery',
732
+ objectName: 'Account',
733
+ resultObjectName: 'account',
734
+ statement: `Id ='${accountId}'`,
735
+ fields: [],
736
+ });
737
+ }
738
+ if (userId) {
739
+ allQueries.push({
740
+ queryName: 'QuoteUserQuery',
741
+ objectName: 'User',
742
+ resultObjectName: 'agent',
743
+ statement: `Id ='${userId}'`,
744
+ fields: [],
745
+ });
746
+ }
747
+ const queries = allQueries.map(query => this.queryObject(query, { properties })) || [];
748
+ return forkJoin([...queries])
749
+ .pipe(defaultIfEmpty([]))
750
+ .pipe(map(results => {
751
+ var _a, _b, _c, _d;
752
+ const queriesResult = _.chain(results)
753
+ .reduce((acc, r) => {
754
+ if (r) {
755
+ return Object.assign(Object.assign({}, acc), r);
756
+ }
757
+ return acc;
758
+ }, {})
759
+ .value();
760
+ const templateProperties = ((template === null || template === void 0 ? void 0 : template.properties) || []).reduce((trunk, { name, value }) => {
761
+ return Object.assign(Object.assign({}, trunk), { [name]: mapBooleanIfAplicable(value) });
762
+ }, {});
763
+ const data = Object.assign(Object.assign(Object.assign({}, (typeof object === 'object' ? object : { object })), queriesResult), templateProperties);
764
+ if (template.script && template.script.trim().length) {
765
+ const currencyFormat = ((_b = (_a = template.properties) === null || _a === void 0 ? void 0 : _a.find(({ name }) => name === 'currencyFormat')) === null || _b === void 0 ? void 0 : _b.value) || '1.2-2';
766
+ const dateFormat = ((_d = (_c = template.properties) === null || _c === void 0 ? void 0 : _c.find(({ name }) => name === 'dateFormat')) === null || _d === void 0 ? void 0 : _d.value) || 'D/MMM/YYYY';
767
+ const formatDate = (value) => {
768
+ return value ? moment(value).format(dateFormat) : value;
769
+ };
770
+ const transform = new Function(`return ${template.script}`)();
771
+ const transformedData = transform(Object.assign(Object.assign({}, data), { utils: {
772
+ lodash: _,
773
+ currency: (value) => new CurrencyPipe('en-US').transform(value, 'USD', 'symbol', currencyFormat),
774
+ date: formatDate,
775
+ }, ToDay: formatDate(Date.now()) }));
776
+ if (!shouldPreventDownload) {
777
+ const blob = new Blob([JSON.stringify(transformedData)]);
778
+ this.fileDownloadService.processDownload(blob, 'data.json');
779
+ }
780
+ return transformedData;
781
+ }
782
+ return data;
783
+ }));
784
+ }
785
+ generateDocument(template, object, params = {}) {
786
+ const attachmentIds = (template.attachments || []).map(({ id }) => id).filter(Boolean);
787
+ const { shouldUseLocalDocxTemplater } = params;
788
+ return shouldUseLocalDocxTemplater && !(object instanceof QuoteDraft)
789
+ ? this.generateDocumentNew(template, object, params)
790
+ : this.generateWithBackendDocxTemplater({ template, quote: object, attachmentIds, params });
791
+ }
792
+ generateDocumentNew(template, object, params = {}) {
793
+ const { attachToQuote, documentFormat, shouldPreventDownload } = params;
794
+ const file$ = this.service.api({
795
+ method: 'get',
796
+ url: `/templates/${template.id}/file`,
797
+ responseType: 'arraybuffer',
798
+ });
799
+ const attachmentIds = (template.attachments || []).map(({ id }) => id);
800
+ const attachments$ = attachmentIds.length
801
+ ? attachmentIds.map(attachmentId => {
802
+ return this.documentAttachmentService.getAttachmentFile(attachmentId, true);
803
+ })
804
+ : [];
805
+ const data$ = this.generateDocumentData(template, object, Object.assign(Object.assign({}, params), { shouldPreventDownload: true }));
806
+ return zip(file$, data$, ...attachments$).pipe(switchMap(([file, data, ...attachments]) => {
807
+ var _a;
808
+ const d = DocxTemplater.generate(file, data);
809
+ const body = new FormData();
810
+ const 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) || {};
811
+ const documentName = (properties === null || properties === void 0 ? void 0 : properties.Name) || template.name;
812
+ // TODO: special CATO case. Refactor for a more generic approach
813
+ if (documentFormat === 'DOCX') {
814
+ this.fileDownloadService.processDownload(d, documentName);
815
+ return of(d);
816
+ }
817
+ attachments.forEach((attachment) => {
818
+ body.append('attachments', new Blob([attachment]));
819
+ });
820
+ body.append('orderform', d);
821
+ return this.http
822
+ .post(`${this.docGenHost}/documents/merge`, body, {
823
+ responseType: 'arraybuffer',
824
+ })
825
+ .pipe(switchMap((pdf) => {
826
+ const blob = new Blob([pdf]);
827
+ if (!shouldPreventDownload) {
828
+ this.fileDownloadService.processDownload(blob, `${documentName}.pdf`);
829
+ }
830
+ if (attachToQuote && object instanceof QuoteDraft) {
831
+ const formData = new FormData();
832
+ formData.append('file', blob, `${documentName}.pdf`);
833
+ return this.http.post(`${window['VELO_API']}/services/quotes/${object.quoteId}/attach-document`, formData, {
834
+ responseType: 'arraybuffer',
835
+ headers: {
836
+ Authorization: window['VELO_KEY'],
837
+ },
838
+ });
839
+ }
840
+ return of(blob);
841
+ }));
842
+ }));
843
+ }
844
+ getAttachments(searchRequest) {
845
+ return this.documentAttachmentService.getAttachments(searchRequest);
846
+ }
847
+ getAttachmentFile(id) {
848
+ return this.documentAttachmentService.getAttachmentFile(id);
849
+ }
850
+ createAttachment(attachment, file, reportProgress) {
851
+ return this.documentAttachmentService.createAttachment(attachment, file, reportProgress);
852
+ }
853
+ removeAttachment(id) {
854
+ return this.documentAttachmentService.removeAttachment(id);
855
+ }
856
+ downloadTemplateFile(id) {
857
+ return this.service
858
+ .api({
859
+ url: `/templates/${id}/file`,
860
+ responseType: 'blob',
861
+ observe: 'response',
862
+ })
863
+ .pipe(tap(response => {
864
+ this.fileDownloadService.processDownload(response);
865
+ }), map(response => response.body || response));
866
+ }
867
+ generateWithBackendDocxTemplater({ template, quote, attachmentIds, params, }) {
868
+ const { shouldPreventDownload } = params;
869
+ const nonEmptyParams = Object.keys(params || {})
870
+ .filter(k => params[k] !== undefined)
871
+ .reduce((obj, key) => {
872
+ obj[key] = params[key];
873
+ return obj;
874
+ }, {});
875
+ return this.generate(`/templates/${template.id}/generate`, { quote, attachments: attachmentIds }, Boolean(shouldPreventDownload), 'blob', nonEmptyParams, false);
876
+ }
877
+ generate(url, body, shouldPreventDownload, responseType, params, isUpload, reportProgress) {
878
+ const requestOptions = {
879
+ method: 'post',
880
+ url,
881
+ body,
882
+ reportProgress,
883
+ responseType,
884
+ observe: shouldPreventDownload ? 'body' : 'response',
885
+ params,
886
+ };
887
+ return (isUpload ? this.service.upload(requestOptions) : this.service.api(requestOptions)).pipe(tap(response => {
888
+ if (!shouldPreventDownload) {
889
+ this.fileDownloadService.processDownload(response);
890
+ }
891
+ }));
892
+ }
893
+ queryObject({ objectName, resultObjectName, fields, statement }, { properties }) {
894
+ var _a;
895
+ const patternLimit = /(\s*limit\s\d*)/i;
896
+ let limit = 1;
897
+ if (patternLimit.test(statement)) {
898
+ const limitStr = (_a = statement === null || statement === void 0 ? void 0 : statement.match(patternLimit)) === null || _a === void 0 ? void 0 : _a[1].trim().substring(5).trim();
899
+ if (limitStr) {
900
+ limit = Number.parseInt(limitStr, 10);
901
+ }
902
+ statement = statement.replace(patternLimit, '');
903
+ }
904
+ const resolvedStatement = StringUtils.fillPlaceholders(statement, properties, /:\s*(\w[\w\d_.]+)/i);
905
+ const searchRequest = Object.assign({ skip: 0, count: limit, rawCondition: resolvedStatement }, ((fields === null || fields === void 0 ? void 0 : fields.length) && !!fields[0] && { fields }));
906
+ return this.sfRepo.query(searchRequest, objectName).pipe(mapSfQueryResult(limit), map(value => ({ [resultObjectName]: value })));
907
+ }
908
+ }
909
+ DocumentTemplatesApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentTemplatesApiService, deps: [{ token: i1.BaseHttpService }, { token: SalesforceApiService }, { token: i1.FileDownloadService }, { token: DocumentAttachmentApiService }, { token: i4.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
910
+ DocumentTemplatesApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentTemplatesApiService });
911
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: DocumentTemplatesApiService, decorators: [{
912
+ type: Injectable
913
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }, { type: SalesforceApiService }, { type: i1.FileDownloadService }, { type: DocumentAttachmentApiService }, { type: i4.HttpClient }]; } });
914
+
915
+ class PriceApiService {
916
+ constructor(httpService) {
917
+ this.httpService = httpService;
918
+ this.SERVICE_URL = '/price';
919
+ }
920
+ calculateRuntime(request) {
921
+ return this.httpService.api({
922
+ method: 'post',
923
+ url: `${this.SERVICE_URL}/calculate-runtime`,
924
+ body: request,
925
+ });
926
+ }
927
+ calculate(request) {
928
+ return this.httpService.api({
929
+ method: 'post',
930
+ url: `${this.SERVICE_URL}/calculate`,
931
+ body: request,
932
+ });
933
+ // TODO: move outside API service
934
+ // .pipe(
935
+ // map(data => {
936
+ // if (data.context) {
937
+ // const context = this.contextService.resolveOrCreate();
938
+ // const patchedContext = {
939
+ // ...context,
940
+ // properties: {
941
+ // ...context.properties,
942
+ // ...data.context.properties,
943
+ // },
944
+ // };
945
+ // this.contextService.update(patchedContext);
946
+ // }
947
+ // return data;
948
+ // }),
949
+ // );
950
+ }
951
+ getPriceLists() {
952
+ return this.httpService.api({
953
+ method: 'get',
954
+ url: '/price-lists',
955
+ });
956
+ }
957
+ getPriceList(id) {
958
+ return this.httpService.api({
959
+ method: 'get',
960
+ url: `/price-lists/${id}`,
961
+ });
962
+ }
963
+ getSellingTermByEndDate(planId, offeringId, startDate, endDate, frequencyUnit, frequencyDuration) {
964
+ return this.httpService.api({
965
+ method: 'post',
966
+ url: `${this.SERVICE_URL}/selling-term-by-end-date`,
967
+ body: {
968
+ planId: planId,
969
+ offeringId: offeringId,
970
+ startDate: startDate,
971
+ endDate: endDate,
972
+ frequencyUnit: frequencyUnit,
973
+ frequencyDuration: frequencyDuration,
974
+ },
975
+ });
976
+ }
977
+ getSellingTermByTerm(planId, offeringId, startDate, term, frequencyUnit, frequencyDuration) {
978
+ return this.httpService.api({
979
+ method: 'post',
980
+ url: `${this.SERVICE_URL}/selling-term-by-term`,
981
+ body: {
982
+ planId: planId,
983
+ offeringId: offeringId,
984
+ startDate: startDate,
985
+ term: term,
986
+ frequencyUnit: frequencyUnit,
987
+ frequencyDuration: frequencyDuration,
988
+ },
989
+ });
990
+ }
991
+ }
992
+ PriceApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PriceApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
993
+ PriceApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PriceApiService });
994
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PriceApiService, decorators: [{
995
+ type: Injectable
996
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
997
+
998
+ class ProductModelApiService {
999
+ constructor(httpService) {
1000
+ this.httpService = httpService;
1001
+ this.SERVICE_URL = '/models';
1002
+ }
1003
+ addModel(model) {
1004
+ return this.httpService
1005
+ .api({
1006
+ method: 'post',
1007
+ url: this.SERVICE_URL,
1008
+ body: model,
1009
+ errorHandler: this.httpService.handleValidationError,
1010
+ })
1011
+ .pipe(map(result => {
1012
+ if (result.successful) {
1013
+ return result;
1014
+ }
1015
+ else {
1016
+ throw new Error(result.message);
1017
+ }
1018
+ }));
1019
+ }
1020
+ releaseModel(model) {
1021
+ return this.httpService
1022
+ .api({
1023
+ method: 'put',
1024
+ url: `${this.SERVICE_URL}/${model.id}/release`,
1025
+ body: model,
1026
+ errorHandler: this.httpService.handleValidationError,
1027
+ })
1028
+ .pipe(map(result => {
1029
+ if (result.successful) {
1030
+ return '';
1031
+ }
1032
+ else {
1033
+ throw new Error(result.message);
1034
+ }
1035
+ }));
1036
+ }
1037
+ removeModel(modelId, successFn, failureFn) {
1038
+ const observable = this.httpService
1039
+ .api({
1040
+ method: 'delete',
1041
+ url: `${this.SERVICE_URL}/${modelId}`,
1042
+ errorHandler: this.httpService.handleValidationError,
1043
+ })
1044
+ .pipe(map(result => {
1045
+ if (result.successful) {
1046
+ return '';
1047
+ }
1048
+ else {
1049
+ throw new Error(result.message);
1050
+ }
1051
+ }));
1052
+ observable.subscribe(() => {
1053
+ successFn && successFn.apply();
1054
+ }, () => {
1055
+ failureFn && failureFn.apply();
1056
+ });
1057
+ }
1058
+ getModelVersions(modelId, count = 100, skip = 0) {
1059
+ return this.httpService.api({
1060
+ method: 'post',
1061
+ url: `${this.SERVICE_URL}/${modelId}/versions`,
1062
+ body: {
1063
+ skipCount: skip,
1064
+ count: count,
1065
+ },
1066
+ });
1067
+ }
1068
+ getModel(id, version) {
1069
+ let url = `${this.SERVICE_URL}/${id}`;
1070
+ if (version) {
1071
+ url += `/versions/${version}`;
1072
+ }
1073
+ return this.httpService.api({ url });
1074
+ }
1075
+ getModels(skipCount, searchText) {
1076
+ return this.httpService.api({
1077
+ method: 'post',
1078
+ url: `${this.SERVICE_URL}/search`,
1079
+ body: {
1080
+ nameRegex: searchText,
1081
+ skipCount: skipCount.toString(),
1082
+ count: ProductModelApiService.MAX_RESULTS,
1083
+ },
1084
+ });
1085
+ }
1086
+ getLinkedModels(id, version) {
1087
+ let url = `${this.SERVICE_URL}/${id}`;
1088
+ if (version) {
1089
+ url += `/versions/${version}`;
1090
+ }
1091
+ url += '/linked';
1092
+ return this.httpService.api({ url }).pipe(map((linkedModels) => {
1093
+ if (linkedModels) {
1094
+ linkedModels.forEach(model => ModelTranslatorUtils.toLocalModel(model));
1095
+ }
1096
+ return linkedModels;
1097
+ }));
1098
+ }
1099
+ load(id, version) {
1100
+ return forkJoin([this.getModel(id, version), this.getLinkedModels(id, version)]).pipe(map(([model, linkedModels]) => {
1101
+ const container = new ProductModelsContainer(model, linkedModels !== null && linkedModels !== void 0 ? linkedModels : []);
1102
+ ModelUtils.override(container.main, container.linked);
1103
+ ModelTranslatorUtils.toLocalModel(container.main, container.linked);
1104
+ return container;
1105
+ }));
1106
+ }
1107
+ getPML(modelId, version) {
1108
+ let url = `${this.SERVICE_URL}/${modelId}/pml/${version}`;
1109
+ if (version) {
1110
+ url += `/versions/${version}`;
1111
+ }
1112
+ return this.httpService.api({
1113
+ url,
1114
+ responseType: 'text',
1115
+ });
1116
+ }
1117
+ savePML(modelId, pml, comment) {
1118
+ return this.httpService
1119
+ .api({
1120
+ method: 'put',
1121
+ url: `${this.SERVICE_URL}/${modelId}/pml`,
1122
+ body: {
1123
+ id: modelId,
1124
+ pml: pml,
1125
+ comment: comment,
1126
+ },
1127
+ })
1128
+ .pipe(map(result => {
1129
+ if (result.successful) {
1130
+ return '';
1131
+ }
1132
+ else {
1133
+ throw new Error(result.message);
1134
+ }
1135
+ }), catchError(this.httpService.handleValidationError));
1136
+ }
1137
+ generateProducts(modelId) {
1138
+ return this.httpService.api({
1139
+ url: `${this.SERVICE_URL}/${modelId}/generate-products`,
1140
+ });
1141
+ }
1142
+ saveModel(productModel, comment) {
1143
+ const model = EntityUtil.clone(productModel);
1144
+ model.comment = comment;
1145
+ ModelTranslatorUtils.toServerModel(model);
1146
+ return this.httpService
1147
+ .api({
1148
+ method: 'put',
1149
+ url: `${this.SERVICE_URL}/${model.id}`,
1150
+ body: model,
1151
+ })
1152
+ .pipe(map(result => {
1153
+ if (result.successful) {
1154
+ return '';
1155
+ }
1156
+ else {
1157
+ throw new Error(result.message);
1158
+ }
1159
+ }), catchError(this.httpService.handleValidationError));
1160
+ }
1161
+ validateModel(productModel) {
1162
+ return this.httpService
1163
+ .api({
1164
+ method: 'post',
1165
+ url: `${this.SERVICE_URL}/validate`,
1166
+ body: productModel,
1167
+ errorHandler: this.httpService.handleValidationError,
1168
+ })
1169
+ .pipe(map(result => {
1170
+ if (result.successful) {
1171
+ return '';
1172
+ }
1173
+ else {
1174
+ throw new Error(result.message);
1175
+ }
1176
+ }));
1177
+ }
1178
+ renameModel(productModel, name) {
1179
+ const model = EntityUtil.clone(productModel);
1180
+ model.name = name;
1181
+ ModelTranslatorUtils.toServerModel(model);
1182
+ return this.httpService
1183
+ .api({
1184
+ method: 'patch',
1185
+ url: `${this.SERVICE_URL}/${model.id}`,
1186
+ body: model,
1187
+ })
1188
+ .pipe(catchError(this.httpService.handleValidationError));
1189
+ }
1190
+ uploadPmlFile(file, modelId) {
1191
+ const formData = new FormData();
1192
+ formData.append('file', file, file.name);
1193
+ return this.httpService.upload({
1194
+ url: `${this.SERVICE_URL}/${modelId}/pml/upload`,
1195
+ body: formData,
1196
+ });
1197
+ }
1198
+ runPml(modelId, pml, rootType, configurationMode) {
1199
+ return this.httpService.api({
1200
+ method: 'post',
1201
+ url: `${this.SERVICE_URL}/${modelId}/pml/run`,
1202
+ body: {
1203
+ pml,
1204
+ rootType,
1205
+ configurationMode,
1206
+ },
1207
+ responseType: 'text',
1208
+ });
1209
+ }
1210
+ evictAllCache() {
1211
+ return this.httpService.api({
1212
+ method: 'get',
1213
+ url: '/cache/evict/environment-variables',
1214
+ });
1215
+ }
1216
+ }
1217
+ ProductModelApiService.MAX_RESULTS = 200;
1218
+ ProductModelApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ProductModelApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1219
+ ProductModelApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ProductModelApiService });
1220
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ProductModelApiService, decorators: [{
1221
+ type: Injectable
1222
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1223
+
1224
+ class QuoteApiService {
1225
+ constructor(httpService) {
1226
+ this.httpService = httpService;
1227
+ this.SERVICE_URL = '/quotes';
1228
+ }
1229
+ getQuote(quoteId, params) {
1230
+ return this.httpService.api({
1231
+ method: 'get',
1232
+ url: `${this.SERVICE_URL}/${quoteId}`,
1233
+ params,
1234
+ });
1235
+ }
1236
+ upsertQuote(request) {
1237
+ return this.httpService.api({
1238
+ method: 'post',
1239
+ url: `${this.SERVICE_URL}`,
1240
+ body: request,
1241
+ });
1242
+ }
1243
+ submitQuote(request) {
1244
+ return this.httpService.api({
1245
+ method: 'post',
1246
+ url: `${this.SERVICE_URL}/submit`,
1247
+ body: request,
1248
+ });
1249
+ }
1250
+ }
1251
+ QuoteApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1252
+ QuoteApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteApiService });
1253
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteApiService, decorators: [{
1254
+ type: Injectable
1255
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1256
+
1257
+ class RampApiService {
1258
+ constructor(httpService) {
1259
+ this.httpService = httpService;
1260
+ this.SERVICE_URL = '/ramp';
1261
+ }
1262
+ next(request) {
1263
+ return this.httpService.api({
1264
+ method: 'post',
1265
+ url: `${this.SERVICE_URL}/next`,
1266
+ body: request,
1267
+ });
1268
+ }
1269
+ renew(request) {
1270
+ return this.httpService.api({
1271
+ method: 'post',
1272
+ url: `${this.SERVICE_URL}/renew`,
1273
+ body: request,
1274
+ });
1275
+ // TODO: move out of API service
1276
+ // .pipe(
1277
+ // map(data => {
1278
+ // if (data.context) {
1279
+ // const context = this.contextService.resolveOrCreate();
1280
+ // Object.keys(data.context.properties).forEach(function (key) {
1281
+ // context.properties[key] = data.context.properties[key];
1282
+ // });
1283
+ // this.contextService.update(context);
1284
+ // }
1285
+ // return data;
1286
+ // }),
1287
+ // );
1288
+ }
1289
+ }
1290
+ RampApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RampApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1291
+ RampApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RampApiService });
1292
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: RampApiService, decorators: [{
1293
+ type: Injectable
1294
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1295
+
1296
+ const fromUIComponentStoryDTO = (dto, attachments) => {
1297
+ return {
1298
+ id: dto.id,
1299
+ name: dto.name,
1300
+ uiComponentId: dto.uiComponentId,
1301
+ description: dto.description,
1302
+ templateHtmlId: dto.templateHtmlId,
1303
+ scriptJsId: dto.scriptJsId,
1304
+ styleCssId: dto.styleCssId,
1305
+ sectionJsonId: dto.sectionJsonId,
1306
+ section: attachments.json,
1307
+ template: attachments.html,
1308
+ script: attachments.js,
1309
+ styles: attachments.css,
1310
+ };
1311
+ };
1312
+
1313
+ class UITemplatesApiService {
1314
+ constructor(baseHttpService) {
1315
+ this.baseHttpService = baseHttpService;
1316
+ this.serviceUrl = '/uitemplates';
1317
+ this.fetchTemplates$ = (name) => {
1318
+ let params = new HttpParams();
1319
+ if (name) {
1320
+ params = params.append('name', name);
1321
+ }
1322
+ return this.baseHttpService.api({ url: `${this.serviceUrl}`, params });
1323
+ };
1324
+ this.createTemplate$ = (template) => {
1325
+ return this.baseHttpService.api({
1326
+ method: 'post',
1327
+ url: `${this.serviceUrl}`,
1328
+ body: template,
1329
+ });
1330
+ };
1331
+ this.updateTemplate$ = (template) => {
1332
+ return this.baseHttpService.api({
1333
+ method: 'put',
1334
+ url: `${this.serviceUrl}/${template.id}`,
1335
+ body: template,
1336
+ });
1337
+ };
1338
+ this.duplicateTemplate$ = (template) => {
1339
+ // TODO: integrate with BE
1340
+ return of(UUID.UUID());
1341
+ };
1342
+ this.removeTemplate$ = (id) => {
1343
+ return this.baseHttpService.api({
1344
+ method: 'delete',
1345
+ url: `${this.serviceUrl}/${id}`,
1346
+ });
1347
+ };
1348
+ this.restoreTemplate$ = (id) => {
1349
+ return this.baseHttpService.api({
1350
+ method: 'patch',
1351
+ url: `${this.serviceUrl}/${id}`,
1352
+ });
1353
+ };
1354
+ this.searchTemplates$ = (data) => {
1355
+ return this.baseHttpService.api({
1356
+ method: 'post',
1357
+ url: `${this.serviceUrl}/search`,
1358
+ params: data.params,
1359
+ body: data.expression,
1360
+ });
1361
+ };
1362
+ this.fetchComponents$ = (templateId, name) => {
1363
+ let params = new HttpParams();
1364
+ if (name) {
1365
+ params = params.append('name', name);
1366
+ }
1367
+ return this.baseHttpService.api({
1368
+ url: `${this.serviceUrl}/${templateId}/components`,
1369
+ params,
1370
+ });
1371
+ };
1372
+ this.fetchComponent$ = (templateId, componentId) => {
1373
+ return this.baseHttpService.api({
1374
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}`,
1375
+ });
1376
+ };
1377
+ this.createComponent$ = (component) => {
1378
+ return this.baseHttpService.api({
1379
+ method: 'post',
1380
+ url: `${this.serviceUrl}/${component.uiTemplateId}/components`,
1381
+ body: component,
1382
+ });
1383
+ };
1384
+ this.updateComponent$ = (component) => {
1385
+ return this.baseHttpService.api({
1386
+ method: 'put',
1387
+ url: `${this.serviceUrl}/${component.uiTemplateId}/components/${component.id}`,
1388
+ body: component,
1389
+ });
1390
+ };
1391
+ this.duplicateComponent$ = (component) => {
1392
+ // TODO: integrate with BE
1393
+ return of(UUID.UUID());
1394
+ };
1395
+ this.removeComponent$ = (templateId, componentId) => {
1396
+ return this.baseHttpService.api({
1397
+ method: 'delete',
1398
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}`,
1399
+ });
1400
+ };
1401
+ this.restoreComponent$ = (templateId, componentId) => {
1402
+ return this.baseHttpService.api({
1403
+ method: 'patch',
1404
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}`,
1405
+ });
1406
+ };
1407
+ this.searchComponents$ = (templateId, data) => {
1408
+ return this.baseHttpService.api({
1409
+ method: 'post',
1410
+ url: `${this.serviceUrl}/${templateId}/components/search`,
1411
+ params: data.params,
1412
+ body: data.expression,
1413
+ });
1414
+ };
1415
+ this.fetchStoryAttachment = (templateId, componentId, storyId, type) => {
1416
+ return this.baseHttpService
1417
+ .api({
1418
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}/attachments/${type}/file`,
1419
+ responseType: 'text',
1420
+ })
1421
+ .pipe(catchError$1(() => of('')));
1422
+ };
1423
+ this.convertToComponentStory$ = (templateId, componentId, storyDto) => {
1424
+ return forkJoin([
1425
+ storyDto.templateHtmlId ? this.fetchStoryAttachment(templateId, componentId, storyDto.id, 'html') : of(undefined),
1426
+ storyDto.scriptJsId ? this.fetchStoryAttachment(templateId, componentId, storyDto.id, 'js') : of(undefined),
1427
+ storyDto.styleCssId ? this.fetchStoryAttachment(templateId, componentId, storyDto.id, 'css') : of(undefined),
1428
+ storyDto.sectionJsonId ? this.fetchStoryAttachment(templateId, componentId, storyDto.id, 'json') : of(undefined),
1429
+ ]).pipe(map$1(([html, js, css, json]) => ({ html, js, css, json })), map$1(attachments => fromUIComponentStoryDTO(storyDto, attachments)));
1430
+ };
1431
+ this.fetchStories$ = (templateId, componentId, name) => {
1432
+ let params = new HttpParams();
1433
+ if (name) {
1434
+ params = params.append('name', name);
1435
+ }
1436
+ return this.baseHttpService
1437
+ .api({
1438
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories`,
1439
+ params,
1440
+ })
1441
+ .pipe(switchMap$1(dtos => {
1442
+ if (!dtos.length) {
1443
+ return of([]);
1444
+ }
1445
+ return forkJoin(dtos.map(dto => this.convertToComponentStory$(templateId, componentId, dto)));
1446
+ }));
1447
+ };
1448
+ this.fetchStory$ = (templateId, componentId, storyId) => {
1449
+ return this.baseHttpService
1450
+ .api({
1451
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}`,
1452
+ })
1453
+ .pipe(switchMap$1(dto => this.convertToComponentStory$(templateId, componentId, dto)));
1454
+ };
1455
+ this.createComponentStory$ = (templateId, story) => {
1456
+ return this.baseHttpService.api({
1457
+ method: 'post',
1458
+ url: `${this.serviceUrl}/${templateId}/components/${story.uiComponentId}/stories`,
1459
+ body: story,
1460
+ });
1461
+ };
1462
+ this.updateComponentStory$ = (templateId, story) => {
1463
+ const { script, template, styles, section } = story, rest = __rest(story, ["script", "template", "styles", "section"]);
1464
+ return this.baseHttpService
1465
+ .api({
1466
+ method: 'put',
1467
+ url: `${this.serviceUrl}/${templateId}/components/${story.uiComponentId}/stories/${story.id}`,
1468
+ body: rest,
1469
+ })
1470
+ .pipe(map$1(dto => fromUIComponentStoryDTO(dto, { html: template, js: script, css: styles, json: section })));
1471
+ };
1472
+ this.deleteComponentStory$ = (templateId, componentId, storyId) => {
1473
+ return this.baseHttpService.api({
1474
+ method: 'delete',
1475
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}`,
1476
+ });
1477
+ };
1478
+ this.restoreComponentStory$ = (templateId, componentId, storyId) => {
1479
+ return this.baseHttpService.api({
1480
+ method: 'patch',
1481
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}`,
1482
+ });
1483
+ };
1484
+ this.uploadStoryAttachments$ = (templateId, componentId, storyId, attachments) => {
1485
+ const formData = new FormData();
1486
+ if (attachments.html != null) {
1487
+ formData.append('html', new Blob([attachments.html]), 'story-template.html');
1488
+ }
1489
+ if (attachments.css != null) {
1490
+ formData.append('css', new Blob([attachments.css]), 'story-styles.css');
1491
+ }
1492
+ if (attachments.js != null) {
1493
+ formData.append('js', new Blob([attachments.js]), 'story-script.js');
1494
+ }
1495
+ if (attachments.json != null) {
1496
+ formData.append('json', new Blob([attachments.json]), 'story-section.json');
1497
+ }
1498
+ return this.baseHttpService.upload({
1499
+ method: 'post',
1500
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}/attachments`,
1501
+ body: formData,
1502
+ });
1503
+ };
1504
+ this.fetchComponentAttachments$ = (templateId, component) => {
1505
+ return forkJoin([
1506
+ component.templateHtmlId ? this.fetchComponentAttachmentFile$(templateId, component.id, 'html') : of(undefined),
1507
+ component.scriptJsId ? this.fetchComponentAttachmentFile$(templateId, component.id, 'js') : of(undefined),
1508
+ component.styleCssId ? this.fetchComponentAttachmentFile$(templateId, component.id, 'css') : of(undefined),
1509
+ component.propertiesJsonId ? this.fetchComponentAttachmentFile$(templateId, component.id, 'json') : of(undefined),
1510
+ ]).pipe(map$1(([html, js, css, json]) => ({ html, js, css, json })));
1511
+ };
1512
+ this.fetchComponentAttachmentFile$ = (templateId, componentId, attachmentType) => {
1513
+ return this.baseHttpService
1514
+ .api({
1515
+ method: 'get',
1516
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/attachments/${attachmentType}/file`,
1517
+ responseType: 'text',
1518
+ })
1519
+ .pipe(catchError$1(() => of('')));
1520
+ };
1521
+ this.uploadComponentAttachments$ = (templateId, componentId, attachments) => {
1522
+ const formData = new FormData();
1523
+ if (attachments.html != null) {
1524
+ formData.append('html', new Blob([attachments.html]), 'template.html');
1525
+ }
1526
+ if (attachments.css != null) {
1527
+ formData.append('css', new Blob([attachments.css]), 'styles.css');
1528
+ }
1529
+ if (attachments.js != null) {
1530
+ formData.append('js', new Blob([attachments.js]), 'script.js');
1531
+ }
1532
+ if (attachments.json != null) {
1533
+ formData.append('json', new Blob([attachments.json]), 'section.json');
1534
+ }
1535
+ return this.baseHttpService.upload({
1536
+ method: 'post',
1537
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/attachments`,
1538
+ body: formData,
1539
+ });
1540
+ };
1541
+ }
1542
+ getTemplateThumbnailUrl(templateId) {
1543
+ return `${this.serviceUrl}/${templateId}/thumbnail/file`;
1544
+ }
1545
+ attachTemplateThumbnail$(templateId, file) {
1546
+ const data = new FormData();
1547
+ data.append('thumb', file);
1548
+ return this.baseHttpService.upload({
1549
+ method: 'post',
1550
+ url: `${this.serviceUrl}/${templateId}/thumbnail`,
1551
+ body: data,
1552
+ });
1553
+ }
1554
+ removeTemplateThumbnail$(templateId) {
1555
+ return this.baseHttpService.api({
1556
+ method: 'delete',
1557
+ url: `${this.serviceUrl}/${templateId}/thumbnail`,
1558
+ });
1559
+ }
1560
+ }
1561
+ UITemplatesApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UITemplatesApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1562
+ UITemplatesApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UITemplatesApiService });
1563
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: UITemplatesApiService, decorators: [{
1564
+ type: Injectable
1565
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1566
+
1567
+ class ScriptsApiService {
1568
+ constructor(baseHttpService) {
1569
+ this.baseHttpService = baseHttpService;
1570
+ this.serviceUrl = '/admin/scripts';
1571
+ this.fetchScripts$ = () => {
1572
+ return this.baseHttpService.api({ url: `${this.serviceUrl}` });
1573
+ };
1574
+ this.searchScripts$ = (expression, skip, count) => {
1575
+ let params = new HttpParams();
1576
+ params = params.set('skip', '' + skip);
1577
+ params = params.set('count', '' + count);
1578
+ return this.baseHttpService.api({ method: 'post', url: `${this.serviceUrl}/search`, params, body: expression });
1579
+ };
1580
+ this.fetchScript$ = (id) => {
1581
+ return this.baseHttpService.api({ url: `${this.serviceUrl}/${id}` });
1582
+ };
1583
+ this.createScript$ = (script) => {
1584
+ return this.baseHttpService.api({
1585
+ url: `${this.serviceUrl}`,
1586
+ method: 'post',
1587
+ body: script,
1588
+ });
1589
+ };
1590
+ this.updateScriptMeta$ = (script) => {
1591
+ return this.baseHttpService.api({
1592
+ url: `${this.serviceUrl}/${script.id}`,
1593
+ method: 'post',
1594
+ body: script,
1595
+ });
1596
+ };
1597
+ this.updateScriptDetails$ = (script) => {
1598
+ return this.baseHttpService.api({
1599
+ url: `${this.serviceUrl}/${script.id}`,
1600
+ method: 'put',
1601
+ body: script,
1602
+ });
1603
+ };
1604
+ this.cloneScript$ = (cloneRequest) => {
1605
+ return this.baseHttpService.api({
1606
+ url: `${this.serviceUrl}/${cloneRequest.id}/clone`,
1607
+ method: 'post',
1608
+ body: cloneRequest
1609
+ });
1610
+ };
1611
+ this.removeScript$ = (id) => {
1612
+ return this.baseHttpService.api({
1613
+ url: `${this.serviceUrl}/${id}`,
1614
+ method: 'delete',
1615
+ });
1616
+ };
1617
+ this.restoreScript$ = (id) => {
1618
+ return this.baseHttpService.api({
1619
+ url: `${this.serviceUrl}/${id}/restore`,
1620
+ method: 'patch',
1621
+ });
1622
+ };
1623
+ this.execute$ = (body) => {
1624
+ return this.baseHttpService.api({
1625
+ url: `/scripts/execute`,
1626
+ method: 'post',
1627
+ body,
1628
+ });
1629
+ };
1630
+ }
1631
+ }
1632
+ ScriptsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ScriptsApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1633
+ ScriptsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ScriptsApiService });
1634
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ScriptsApiService, decorators: [{
1635
+ type: Injectable
1636
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1637
+
1638
+ class ApiModule {
1639
+ }
1640
+ ApiModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ApiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1641
+ ApiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ApiModule, imports: [HttpClientModule] });
1642
+ ApiModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ApiModule, providers: [
1643
+ BaseHttpService,
1644
+ XrayService,
1645
+ ConfigurationApiService,
1646
+ ConfigurationSettingsApiService,
1647
+ ContextApiService,
1648
+ DocumentAttachmentApiService,
1649
+ PriceApiService,
1650
+ ProductModelApiService,
1651
+ QuoteApiService,
1652
+ DocumentTemplatesApiService,
1653
+ RampApiService,
1654
+ SalesforceApiService,
1655
+ UITemplatesApiService,
1656
+ ScriptsApiService,
1657
+ ], imports: [[HttpClientModule]] });
1658
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ApiModule, decorators: [{
1659
+ type: NgModule,
1660
+ args: [{
1661
+ imports: [HttpClientModule],
1662
+ providers: [
1663
+ BaseHttpService,
1664
+ XrayService,
1665
+ ConfigurationApiService,
1666
+ ConfigurationSettingsApiService,
1667
+ ContextApiService,
1668
+ DocumentAttachmentApiService,
1669
+ PriceApiService,
1670
+ ProductModelApiService,
1671
+ QuoteApiService,
1672
+ DocumentTemplatesApiService,
1673
+ RampApiService,
1674
+ SalesforceApiService,
1675
+ UITemplatesApiService,
1676
+ ScriptsApiService,
1677
+ ],
1678
+ }]
1679
+ }] });
1680
+
1681
+ /**
1682
+ * Generated bundle index. Do not edit.
1683
+ */
1684
+
1685
+ export { ApiModule, ConfigurationApiService, ConfigurationSettingsApiService, ContextApiService, DocumentAttachmentApiService, DocumentTemplatesApiService, PriceApiService, ProductModelApiService, QuoteApiService, RampApiService, SalesforceApiService, ScriptsApiService, UITemplatesApiService };
1686
+ //# sourceMappingURL=veloce-api.js.map