@veloceapps/api 7.0.0-9 → 7.0.1-1

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 (73) hide show
  1. package/{esm2015/lib/api.module.js → esm2020/lib/api.module.mjs} +6 -6
  2. package/esm2020/lib/services/account-api.service.mjs +80 -0
  3. package/esm2020/lib/services/catalog-admin-api.service.mjs +165 -0
  4. package/{esm2015/lib/services/catalog-api.service.js → esm2020/lib/services/catalog-api.service.mjs} +4 -4
  5. package/esm2020/lib/services/configuration-api.service.mjs +78 -0
  6. package/esm2020/lib/services/configuration-settings-api.service.mjs +96 -0
  7. package/{esm2015/lib/services/context-api.service.js → esm2020/lib/services/context-api.service.mjs} +4 -4
  8. package/{esm2015/lib/services/delta-api.service.js → esm2020/lib/services/delta-api.service.mjs} +4 -4
  9. package/{esm2015/lib/services/document-attachment-api.service.js → esm2020/lib/services/document-attachment-api.service.mjs} +4 -4
  10. package/esm2020/lib/services/document-templates-api.service.mjs +298 -0
  11. package/{esm2015/lib/services/endpoints-api.service.js → esm2020/lib/services/endpoints-api.service.mjs} +4 -4
  12. package/esm2020/lib/services/flows-api.service.mjs +24 -0
  13. package/esm2020/lib/services/guided-sellings-admin-api.service.mjs +65 -0
  14. package/esm2020/lib/services/guided-sellings-api.service.mjs +27 -0
  15. package/{esm2015/lib/services/offers-api.service.js → esm2020/lib/services/offers-api.service.mjs} +4 -4
  16. package/esm2020/lib/services/org-info-api.service.mjs +19 -0
  17. package/{esm2015/lib/services/picklists-api.service.js → esm2020/lib/services/picklists-api.service.mjs} +8 -5
  18. package/{esm2015/lib/services/price-api.service.js → esm2020/lib/services/price-api.service.mjs} +4 -4
  19. package/{esm2015/lib/services/procedures-api.service.js → esm2020/lib/services/procedures-api.service.mjs} +4 -4
  20. package/{esm2015/lib/services/product-api.service.js → esm2020/lib/services/product-api.service.mjs} +4 -4
  21. package/esm2020/lib/services/product-model-api.service.mjs +232 -0
  22. package/esm2020/lib/services/quote-api.service.mjs +58 -0
  23. package/esm2020/lib/services/ramp-api.service.mjs +31 -0
  24. package/{esm2015/lib/services/rule-groups-api.service.js → esm2020/lib/services/rule-groups-api.service.mjs} +4 -4
  25. package/{esm2015/lib/services/rules-api.service.js → esm2020/lib/services/rules-api.service.mjs} +4 -4
  26. package/esm2020/lib/services/salesforce-api.service.mjs +61 -0
  27. package/{esm2015/lib/services/scripts-api.service.js → esm2020/lib/services/scripts-api.service.mjs} +4 -4
  28. package/esm2020/lib/services/shopping-cart-settings-api.service.mjs +28 -0
  29. package/esm2020/lib/services/ui-templates-api.service.mjs +281 -0
  30. package/esm2020/lib/types/dto/configuration-settings-dto.types.mjs +22 -0
  31. package/fesm2015/{veloceapps-api.js → veloceapps-api.mjs} +100 -101
  32. package/fesm2015/veloceapps-api.mjs.map +1 -0
  33. package/fesm2020/veloceapps-api.mjs +2468 -0
  34. package/fesm2020/veloceapps-api.mjs.map +1 -0
  35. package/lib/services/catalog-admin-api.service.d.ts +2 -2
  36. package/lib/services/guided-sellings-admin-api.service.d.ts +2 -2
  37. package/lib/services/quote-api.service.d.ts +1 -1
  38. package/lib/services/ui-templates-api.service.d.ts +3 -3
  39. package/lib/types/dto/offers-dto.types.d.ts +2 -2
  40. package/lib/types/search-request.types.d.ts +1 -1
  41. package/package.json +26 -24
  42. package/bundles/veloceapps-api.umd.js +0 -2880
  43. package/bundles/veloceapps-api.umd.js.map +0 -1
  44. package/esm2015/lib/services/account-api.service.js +0 -50
  45. package/esm2015/lib/services/catalog-admin-api.service.js +0 -165
  46. package/esm2015/lib/services/configuration-api.service.js +0 -72
  47. package/esm2015/lib/services/configuration-settings-api.service.js +0 -61
  48. package/esm2015/lib/services/document-templates-api.service.js +0 -284
  49. package/esm2015/lib/services/flows-api.service.js +0 -24
  50. package/esm2015/lib/services/guided-sellings-admin-api.service.js +0 -65
  51. package/esm2015/lib/services/guided-sellings-api.service.js +0 -27
  52. package/esm2015/lib/services/org-info-api.service.js +0 -20
  53. package/esm2015/lib/services/product-model-api.service.js +0 -232
  54. package/esm2015/lib/services/quote-api.service.js +0 -48
  55. package/esm2015/lib/services/ramp-api.service.js +0 -21
  56. package/esm2015/lib/services/salesforce-api.service.js +0 -43
  57. package/esm2015/lib/services/shopping-cart-settings-api.service.js +0 -28
  58. package/esm2015/lib/services/ui-templates-api.service.js +0 -282
  59. package/esm2015/lib/types/dto/configuration-settings-dto.types.js +0 -22
  60. package/fesm2015/veloceapps-api.js.map +0 -1
  61. package/veloceapps-api.d.ts +0 -5
  62. /package/{esm2015/index.js → esm2020/index.mjs} +0 -0
  63. /package/{esm2015/lib/types/clone-request.types.js → esm2020/lib/types/clone-request.types.mjs} +0 -0
  64. /package/{esm2015/lib/types/delta-request.types.js → esm2020/lib/types/delta-request.types.mjs} +0 -0
  65. /package/{esm2015/lib/types/dto/offers-dto.types.js → esm2020/lib/types/dto/offers-dto.types.mjs} +0 -0
  66. /package/{esm2015/lib/types/dto/ui-template-dto.types.js → esm2020/lib/types/dto/ui-template-dto.types.mjs} +0 -0
  67. /package/{esm2015/lib/types/index.js → esm2020/lib/types/index.mjs} +0 -0
  68. /package/{esm2015/lib/types/org-info.types.js → esm2020/lib/types/org-info.types.mjs} +0 -0
  69. /package/{esm2015/lib/types/price.types.js → esm2020/lib/types/price.types.mjs} +0 -0
  70. /package/{esm2015/lib/types/ramp-request.types.js → esm2020/lib/types/ramp-request.types.mjs} +0 -0
  71. /package/{esm2015/lib/types/search-request.types.js → esm2020/lib/types/search-request.types.mjs} +0 -0
  72. /package/{esm2015/lib/utils/ui-template.utils.js → esm2020/lib/utils/ui-template.utils.mjs} +0 -0
  73. /package/{esm2015/veloceapps-api.js → esm2020/veloceapps-api.mjs} +0 -0
@@ -0,0 +1,2468 @@
1
+ import * as i4 from '@angular/common/http';
2
+ import { HttpParams, HttpErrorResponse, HttpClientModule } from '@angular/common/http';
3
+ import * as i0 from '@angular/core';
4
+ import { Injectable, NgModule } from '@angular/core';
5
+ import * as i1 from '@veloceapps/core';
6
+ import { ModelTranslatorUtils, ConfigurationContextMode, isLegacyDocumentTemplate, DocxTemplater, QuoteDraft, StringUtils, Expression, Operator, ProductModelsContainer, ModelUtils, EntityUtil, RuleGroupTypes, parseJsonSafely, BaseHttpService, XrayService } from '@veloceapps/core';
7
+ import { throwError, of, zip, forkJoin, map as map$1, noop, catchError as catchError$1, switchMap as switchMap$1 } from 'rxjs';
8
+ import { map, catchError, tap, switchMap, defaultIfEmpty } from 'rxjs/operators';
9
+ import * as i2 from 'primeng/api';
10
+ import { CurrencyPipe } from '@angular/common';
11
+ import * as _ from 'lodash';
12
+ import moment from 'moment';
13
+
14
+ class AccountApiService {
15
+ constructor(httpService) {
16
+ this.httpService = httpService;
17
+ this.SERVICE_URL = '/accounts';
18
+ }
19
+ getAccounts$(options) {
20
+ return this.httpService.api({
21
+ method: 'get',
22
+ url: `${this.SERVICE_URL}`,
23
+ ...options,
24
+ });
25
+ }
26
+ searchAccounts$(searchParams, options) {
27
+ const params = new HttpParams({ fromObject: searchParams });
28
+ return this.httpService.api({
29
+ url: `${this.SERVICE_URL}`,
30
+ params: params,
31
+ ...options,
32
+ });
33
+ }
34
+ getAccount$(id, options) {
35
+ return this.httpService.api({
36
+ url: `${this.SERVICE_URL}/${id}`,
37
+ ...options,
38
+ });
39
+ }
40
+ getAssets(accountId, options) {
41
+ return this.httpService.api({ url: `${this.SERVICE_URL}/${accountId}/assets`, ...options });
42
+ }
43
+ getOrders(accountId, options) {
44
+ return this.httpService.api({ url: `${this.SERVICE_URL}/${accountId}/orders`, ...options });
45
+ }
46
+ getQuotes(accountId, options) {
47
+ return this.httpService.api({ url: `${this.SERVICE_URL}/${accountId}/quotes`, ...options });
48
+ }
49
+ getAsset(accountId, assetId, options) {
50
+ return this.httpService.api({
51
+ url: `${this.SERVICE_URL}/${accountId}/assets/${assetId}`,
52
+ ...options,
53
+ });
54
+ }
55
+ getOrder(accountId, orderId, options) {
56
+ return this.httpService.api({
57
+ url: `${this.SERVICE_URL}/${accountId}/orders/${orderId}`,
58
+ ...options,
59
+ });
60
+ }
61
+ getQuote(accountId, quoteId, options) {
62
+ return this.httpService.api({
63
+ url: `${this.SERVICE_URL}/${accountId}/quotes/${quoteId}`,
64
+ ...options,
65
+ });
66
+ }
67
+ quoteToOrder(accountId, quoteId, options) {
68
+ return this.httpService.api({
69
+ url: `${this.SERVICE_URL}/${accountId}/quotes/${quoteId}/to-order`,
70
+ method: 'post',
71
+ body: { id: quoteId },
72
+ ...options,
73
+ });
74
+ }
75
+ orderToAsset(accountId, orderId, options) {
76
+ return this.httpService.api({
77
+ url: `${this.SERVICE_URL}/${accountId}/orders/${orderId}/to-asset`,
78
+ method: 'post',
79
+ body: { id: orderId },
80
+ ...options,
81
+ });
82
+ }
83
+ }
84
+ AccountApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AccountApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
85
+ AccountApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AccountApiService });
86
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AccountApiService, decorators: [{
87
+ type: Injectable
88
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
89
+
90
+ class CatalogAdminApiService {
91
+ constructor(baseHttpService) {
92
+ this.baseHttpService = baseHttpService;
93
+ this.serviceUrl = '/catalogs';
94
+ this.fetchCatalogs$ = (searchParams) => {
95
+ const params = new HttpParams({ fromObject: { ...searchParams } });
96
+ return this.baseHttpService.api({ url: `${this.serviceUrl}`, params });
97
+ };
98
+ this.searchCatalogs$ = (searchParams, expression) => {
99
+ const params = new HttpParams({ fromObject: { ...searchParams } });
100
+ return this.baseHttpService.api({
101
+ method: 'post',
102
+ url: `${this.serviceUrl}/search`,
103
+ params,
104
+ body: expression || {},
105
+ });
106
+ };
107
+ this.fetchCategories$ = (catalogId) => {
108
+ return this.baseHttpService.api({ url: `${this.serviceUrl}/${catalogId}/categories` });
109
+ };
110
+ this.searchProducts$ = (catalogId, categoryId) => {
111
+ return this.baseHttpService.api({
112
+ method: 'post',
113
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/products/search`,
114
+ body: {},
115
+ });
116
+ };
117
+ this.fetchAttributes$ = (catalogId, categoryId) => {
118
+ return this.baseHttpService.api({ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/attributes` });
119
+ };
120
+ this.createNewCatalog$ = (catalogData) => {
121
+ return this.baseHttpService.api({
122
+ url: `${this.serviceUrl}`,
123
+ method: 'post',
124
+ body: catalogData,
125
+ });
126
+ };
127
+ this.duplicateCatalog$ = (cloneRequest) => {
128
+ return this.baseHttpService.api({
129
+ url: `${this.serviceUrl}/${cloneRequest.id}/clone`,
130
+ method: 'post',
131
+ body: cloneRequest,
132
+ });
133
+ };
134
+ this.updateCatalog$ = (data) => {
135
+ return this.baseHttpService.api({
136
+ url: `${this.serviceUrl}/${data.id}`,
137
+ method: 'put',
138
+ body: data,
139
+ });
140
+ };
141
+ this.removeCatalog$ = (id) => {
142
+ return this.baseHttpService.api({
143
+ url: `${this.serviceUrl}/${id}`,
144
+ method: 'delete',
145
+ });
146
+ };
147
+ this.restoreCatalog$ = (id) => {
148
+ return this.baseHttpService.api({
149
+ url: `${this.serviceUrl}/${id}/restore`,
150
+ method: 'patch',
151
+ });
152
+ };
153
+ this.createNewCategory$ = (categoryData) => {
154
+ return this.baseHttpService.api({
155
+ url: `${this.serviceUrl}/${categoryData.catalogId}/categories`,
156
+ method: 'post',
157
+ body: categoryData,
158
+ });
159
+ };
160
+ this.updateCategory$ = (category) => {
161
+ return this.baseHttpService.api({
162
+ url: `${this.serviceUrl}/${category.catalogId}/categories/${category.id}`,
163
+ method: 'put',
164
+ body: category,
165
+ });
166
+ };
167
+ this.duplicateCategory$ = (catalogId, cloneRequest) => {
168
+ return this.baseHttpService.api({
169
+ url: `${this.serviceUrl}/${catalogId}/categories/${cloneRequest.id}/clone`,
170
+ method: 'post',
171
+ body: cloneRequest,
172
+ });
173
+ };
174
+ this.removeCategory$ = (id, catalogId) => {
175
+ return this.baseHttpService.api({
176
+ url: `${this.serviceUrl}/${catalogId}/categories/${id}`,
177
+ method: 'delete',
178
+ });
179
+ };
180
+ this.restoreCategory$ = (id, catalogId) => {
181
+ return this.baseHttpService.api({
182
+ url: `${this.serviceUrl}/${catalogId}/categories/${id}/restore`,
183
+ method: 'patch',
184
+ });
185
+ };
186
+ this.removeAttribute$ = ({ catalogId, categoryId, data, }) => {
187
+ return this.baseHttpService.api({
188
+ method: 'delete',
189
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/attributes/${data.id}`,
190
+ body: data,
191
+ });
192
+ };
193
+ this.restoreAttribute$ = ({ catalogId, categoryId, data, }) => {
194
+ return this.baseHttpService.api({
195
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/attributes/${data.id}/restore`,
196
+ method: 'patch',
197
+ });
198
+ };
199
+ this.createNewAttribute$ = ({ catalogId, categoryId, data, }) => {
200
+ return this.baseHttpService.api({
201
+ method: 'post',
202
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/attributes`,
203
+ body: data,
204
+ });
205
+ };
206
+ this.updateAttribute$ = ({ catalogId, categoryId, data, }) => {
207
+ return this.baseHttpService.api({
208
+ method: 'put',
209
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/attributes/${data.id}`,
210
+ body: data,
211
+ });
212
+ };
213
+ this.searchProductCandidates$ = (catalogId, categoryId, expression, searchParams) => {
214
+ const params = new HttpParams({ fromObject: { ...searchParams } });
215
+ return this.baseHttpService.api({
216
+ method: 'post',
217
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/candidates/search`,
218
+ params,
219
+ body: expression,
220
+ });
221
+ };
222
+ this.addProduct$ = (product, catalogId, categoryId) => {
223
+ return this.baseHttpService.api({
224
+ method: 'post',
225
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/products`,
226
+ body: product,
227
+ });
228
+ };
229
+ this.updateProduct$ = (product, catalogId, categoryId) => {
230
+ return this.baseHttpService.api({
231
+ method: 'put',
232
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/products/${product.id}`,
233
+ body: product,
234
+ });
235
+ };
236
+ this.removeProduct$ = ({ catalogId, categoryId, data, }) => {
237
+ return this.baseHttpService.api({
238
+ method: 'delete',
239
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/products/${data.id}`,
240
+ });
241
+ };
242
+ }
243
+ }
244
+ CatalogAdminApiService.MAX_RESULTS = 60;
245
+ CatalogAdminApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CatalogAdminApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
246
+ CatalogAdminApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CatalogAdminApiService });
247
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CatalogAdminApiService, decorators: [{
248
+ type: Injectable
249
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
250
+
251
+ class CatalogApiService {
252
+ constructor(service) {
253
+ this.service = service;
254
+ this.serviceUrl = '/product-catalogs';
255
+ }
256
+ fetchCatalogs$() {
257
+ return this.service.api({
258
+ method: 'get',
259
+ url: `${this.serviceUrl}`,
260
+ });
261
+ }
262
+ searchCatalogs$(searchParams, expression) {
263
+ const params = new HttpParams({ fromObject: searchParams });
264
+ return this.service.api({
265
+ method: 'post',
266
+ url: `${this.serviceUrl}/search`,
267
+ params,
268
+ body: expression,
269
+ });
270
+ }
271
+ getCatalog$(id) {
272
+ return this.service.api({
273
+ method: 'get',
274
+ url: `${this.serviceUrl}/${id}`,
275
+ });
276
+ }
277
+ fetchCategories$(catalogId) {
278
+ return this.service.api({
279
+ method: 'get',
280
+ url: `${this.serviceUrl}/${catalogId}/categories`,
281
+ });
282
+ }
283
+ fetchCatalogProducts$(catalogId, searchParams, context) {
284
+ const params = new HttpParams({ fromObject: searchParams });
285
+ return this.service.api({
286
+ method: 'post',
287
+ url: `${this.serviceUrl}/${catalogId}/products`,
288
+ params,
289
+ body: context,
290
+ });
291
+ }
292
+ fetchCategoryProducts$(catalogId, categoryId, searchParams, context) {
293
+ const params = new HttpParams({ fromObject: searchParams });
294
+ return this.service.api({
295
+ method: 'post',
296
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/products`,
297
+ params,
298
+ body: context,
299
+ });
300
+ }
301
+ searchCategoryProducts$(catalogId, categoryId, searchParams, searchCriteria, context) {
302
+ const params = new HttpParams({ fromObject: searchParams });
303
+ return this.service.api({
304
+ method: 'post',
305
+ url: `${this.serviceUrl}/${catalogId}/categories/${categoryId}/products/search`,
306
+ params,
307
+ body: {
308
+ configurationContext: context,
309
+ request: { searchCriteria },
310
+ },
311
+ });
312
+ }
313
+ fetchEligibleProducts$(searchParams, context) {
314
+ const params = new HttpParams({ fromObject: searchParams });
315
+ return this.service.api({
316
+ method: 'post',
317
+ url: `${this.serviceUrl}/products`,
318
+ params: params,
319
+ body: context,
320
+ });
321
+ }
322
+ fetchProducts$(searchParams) {
323
+ const params = new HttpParams({ fromObject: searchParams });
324
+ return this.service.api({
325
+ method: 'get',
326
+ url: `${this.serviceUrl}/products`,
327
+ params: params,
328
+ });
329
+ }
330
+ }
331
+ CatalogApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CatalogApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
332
+ CatalogApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CatalogApiService });
333
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CatalogApiService, decorators: [{
334
+ type: Injectable
335
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
336
+
337
+ class ConfigurationApiService {
338
+ constructor(httpService) {
339
+ this.httpService = httpService;
340
+ this.SERVICE_URL = '/configuration';
341
+ }
342
+ configureLineItem({ configurationRequest, runtimeModel, pricingEnabled, }) {
343
+ return this.httpService
344
+ .api({
345
+ method: 'post',
346
+ url: `${this.SERVICE_URL}${pricingEnabled ? '/price' : ''}`,
347
+ body: configurationRequest,
348
+ errorHandler: e => throwError(e),
349
+ })
350
+ .pipe(map(configurePrice => {
351
+ if (runtimeModel) {
352
+ return {
353
+ ...configurePrice,
354
+ lineItem: this.updatePortDomains(configurePrice.lineItem, runtimeModel),
355
+ };
356
+ }
357
+ else {
358
+ return configurePrice;
359
+ }
360
+ }));
361
+ }
362
+ getRuntimeDataByProductId(productId, offeringId) {
363
+ return this.httpService
364
+ .api({
365
+ method: 'get',
366
+ url: `${this.SERVICE_URL}/${productId}/model` + ((offeringId && `/${offeringId}`) || ''),
367
+ })
368
+ .pipe(map(runtimeData => {
369
+ runtimeData.uiDefinitions = JSON.parse(runtimeData.uiDefinitionsSource);
370
+ runtimeData.uiDefinitions.forEach(uiDefinition => {
371
+ ModelTranslatorUtils.toLocalUIDefinition(uiDefinition);
372
+ });
373
+ return runtimeData;
374
+ }));
375
+ }
376
+ getRuntimeDataByModelId(modelId) {
377
+ return this.httpService
378
+ .api({
379
+ method: 'get',
380
+ url: `${this.SERVICE_URL}/${modelId}/model-test`,
381
+ })
382
+ .pipe(map((runtimeData) => {
383
+ runtimeData.uiDefinitions = [];
384
+ return runtimeData;
385
+ }));
386
+ }
387
+ updatePortDomains(lineItem, runtimeModel) {
388
+ const type = runtimeModel.components.get(lineItem.type);
389
+ const portDomains = { ...lineItem.portDomains };
390
+ for (const port of type?.ports ?? []) {
391
+ const portDomain = portDomains[port.name];
392
+ if (portDomain?.properties?.['domainComputation'] === 'false') {
393
+ portDomain.domainTypes = port.domainTypes;
394
+ }
395
+ }
396
+ return {
397
+ ...lineItem,
398
+ lineItems: lineItem.lineItems?.map(i => this.updatePortDomains(i, runtimeModel)),
399
+ portDomains,
400
+ };
401
+ }
402
+ }
403
+ ConfigurationApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
404
+ ConfigurationApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationApiService });
405
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationApiService, decorators: [{
406
+ type: Injectable
407
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
408
+
409
+ class ConfigurationSettingsDTO {
410
+ static fromDTO(dto, key) {
411
+ return {
412
+ id: dto?.id,
413
+ key: dto?.key || key || '',
414
+ value: dto?.value,
415
+ };
416
+ }
417
+ static toDTO(data) {
418
+ return {
419
+ id: data.id,
420
+ key: data.key,
421
+ value: data.value,
422
+ };
423
+ }
424
+ constructor(id, key, value) {
425
+ this.id = id;
426
+ this.key = key;
427
+ this.value = value;
428
+ }
429
+ }
430
+
431
+ class ConfigurationSettingsApiService {
432
+ constructor(httpService, messageService) {
433
+ this.httpService = httpService;
434
+ this.messageService = messageService;
435
+ this.SERVICE_URL = '/configuration-settings';
436
+ }
437
+ fetchSettings(options) {
438
+ return this.httpService
439
+ .api({
440
+ url: `${this.SERVICE_URL}`,
441
+ method: 'get',
442
+ ...options,
443
+ })
444
+ .pipe(map((settings) => settings.map(setting => ConfigurationSettingsDTO.fromDTO(setting))));
445
+ }
446
+ fetchSetting(settingsKey, options) {
447
+ return this.httpService
448
+ .api({
449
+ url: `${this.SERVICE_URL}/byKey/${settingsKey}`,
450
+ method: 'get',
451
+ ...options,
452
+ skipErrorHandler: true,
453
+ })
454
+ .pipe(map((setting) => ConfigurationSettingsDTO.fromDTO(setting, settingsKey)), catchError(err => {
455
+ if (err instanceof HttpErrorResponse && err.status === 404) {
456
+ if (!options?.skipErrorHandler) {
457
+ this.messageService.add({
458
+ severity: 'error',
459
+ summary: `Configuration Setting "${settingsKey}" is not found`,
460
+ sticky: true,
461
+ });
462
+ }
463
+ return of(null);
464
+ }
465
+ throw err;
466
+ }));
467
+ }
468
+ createSetting(setting, options) {
469
+ const request = ConfigurationSettingsDTO.toDTO(setting);
470
+ return this.httpService.api({
471
+ url: `${this.SERVICE_URL}`,
472
+ method: 'post',
473
+ body: {
474
+ ...request,
475
+ },
476
+ ...options,
477
+ });
478
+ }
479
+ updateSetting(setting, options) {
480
+ const request = ConfigurationSettingsDTO.toDTO(setting);
481
+ return this.httpService.api({
482
+ url: `${this.SERVICE_URL}/${request.id}`,
483
+ method: 'put',
484
+ body: {
485
+ ...request,
486
+ },
487
+ ...options,
488
+ });
489
+ }
490
+ removeSetting(setting, options) {
491
+ const request = ConfigurationSettingsDTO.toDTO(setting);
492
+ return this.httpService.api({
493
+ url: `${this.SERVICE_URL}/${request.id}`,
494
+ method: 'delete',
495
+ ...options,
496
+ });
497
+ }
498
+ restoreSetting(settingId, options) {
499
+ return this.httpService.api({
500
+ url: `${this.SERVICE_URL}/${settingId}/restore`,
501
+ method: 'patch',
502
+ ...options,
503
+ });
504
+ }
505
+ clear(name, options) {
506
+ return this.httpService.api({
507
+ method: 'get',
508
+ url: '/cache/evict/' + name,
509
+ ...options,
510
+ });
511
+ }
512
+ }
513
+ ConfigurationSettingsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationSettingsApiService, deps: [{ token: i1.BaseHttpService }, { token: i2.MessageService }], target: i0.ɵɵFactoryTarget.Injectable });
514
+ ConfigurationSettingsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationSettingsApiService });
515
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationSettingsApiService, decorators: [{
516
+ type: Injectable
517
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }, { type: i2.MessageService }]; } });
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: "15.2.8", ngImport: i0, type: ContextApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
536
+ ContextApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextApiService });
537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextApiService, decorators: [{
538
+ type: Injectable
539
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
540
+
541
+ class DeltaApiService {
542
+ constructor(httpService) {
543
+ this.httpService = httpService;
544
+ this.SERVICE_URL = '/delta';
545
+ }
546
+ calculate$(request) {
547
+ return this.httpService.api({
548
+ method: 'post',
549
+ url: `${this.SERVICE_URL}/calculate`,
550
+ body: request,
551
+ skipErrorHandler: true,
552
+ });
553
+ }
554
+ }
555
+ DeltaApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DeltaApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
556
+ DeltaApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DeltaApiService });
557
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DeltaApiService, decorators: [{
558
+ type: Injectable
559
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
560
+
561
+ class DocumentAttachmentApiService {
562
+ constructor(httpService, fileDownloadService) {
563
+ this.httpService = httpService;
564
+ this.fileDownloadService = fileDownloadService;
565
+ this.SERVICE_URL = '/attachments';
566
+ }
567
+ getAttachments(searchRequest) {
568
+ return this.httpService.api({
569
+ url: `${this.SERVICE_URL}/search`,
570
+ method: 'post',
571
+ body: searchRequest,
572
+ });
573
+ }
574
+ createAttachment(attachment, file, reportProgress) {
575
+ const formData = new FormData();
576
+ if (file) {
577
+ formData.append('file', file, file.name);
578
+ }
579
+ formData.append('attachment', new Blob([JSON.stringify(attachment)], {
580
+ type: 'application/json',
581
+ }));
582
+ return this.httpService.upload({
583
+ url: `${this.SERVICE_URL}`,
584
+ body: formData,
585
+ method: 'post',
586
+ observe: reportProgress ? 'events' : undefined,
587
+ reportProgress,
588
+ });
589
+ }
590
+ updateAttachment(id, attachment) {
591
+ return this.httpService.api({
592
+ url: `${this.SERVICE_URL}/${id}`,
593
+ body: attachment,
594
+ method: 'put',
595
+ });
596
+ }
597
+ getAttachmentFile(id, isPreventDownload) {
598
+ return this.httpService
599
+ .api({
600
+ url: `${this.SERVICE_URL}/${id}/file`,
601
+ responseType: isPreventDownload ? 'arraybuffer' : 'blob',
602
+ observe: isPreventDownload ? 'body' : 'response',
603
+ })
604
+ .pipe(tap(response => {
605
+ if (!isPreventDownload) {
606
+ this.fileDownloadService.processDownload(response);
607
+ }
608
+ }), map(response => (isPreventDownload ? new Blob([response.body || response]) : response.body || response)));
609
+ }
610
+ removeAttachment(id) {
611
+ return this.httpService.api({
612
+ url: `${this.SERVICE_URL}/${id}`,
613
+ method: 'delete',
614
+ });
615
+ }
616
+ }
617
+ DocumentAttachmentApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DocumentAttachmentApiService, deps: [{ token: i1.BaseHttpService }, { token: i1.FileDownloadService }], target: i0.ɵɵFactoryTarget.Injectable });
618
+ DocumentAttachmentApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DocumentAttachmentApiService });
619
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DocumentAttachmentApiService, decorators: [{
620
+ type: Injectable
621
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }, { type: i1.FileDownloadService }]; } });
622
+
623
+ class SalesforceApiService {
624
+ constructor(httpService) {
625
+ this.httpService = httpService;
626
+ this.SERVICE_URL = '/proxy';
627
+ }
628
+ query(searchRequest, objectName, options) {
629
+ return this.httpService.api({
630
+ method: 'post',
631
+ body: { ...searchRequest, count: searchRequest.count || 100 },
632
+ url: `${this.SERVICE_URL}/query/${objectName}`,
633
+ ...options,
634
+ });
635
+ }
636
+ queryObjects(search, options) {
637
+ let params = new HttpParams();
638
+ if (search) {
639
+ params = params.append('search', search);
640
+ }
641
+ return this.httpService.api({
642
+ url: `${this.SERVICE_URL}/query`,
643
+ params,
644
+ ...options,
645
+ });
646
+ }
647
+ search(req, options) {
648
+ return this.httpService.api({
649
+ url: `${this.SERVICE_URL}/rest/search`,
650
+ params: { q: req.searchString },
651
+ ...options,
652
+ });
653
+ }
654
+ describe(objectName, fieldName, options) {
655
+ const methodUrl = `${this.SERVICE_URL}/describe/${objectName}/fields` + (fieldName ? `/${fieldName}` : '');
656
+ return this.httpService.api({ url: methodUrl, ...options });
657
+ }
658
+ describe2(objectName, fields, options) {
659
+ const methodUrl = `${this.SERVICE_URL}/describe/${objectName}/fields`;
660
+ return this.httpService.api({ method: 'post', url: methodUrl, body: fields, ...options });
661
+ }
662
+ apexGetRequest(path, params, options) {
663
+ return this.httpService.api({ url: `${this.SERVICE_URL}/apex${path}`, params, ...options });
664
+ }
665
+ apexPostRequest(path, body, options) {
666
+ return this.httpService.api({
667
+ method: 'post',
668
+ body,
669
+ url: `${this.SERVICE_URL}/apex${path}`,
670
+ ...options,
671
+ });
672
+ }
673
+ }
674
+ SalesforceApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SalesforceApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
675
+ SalesforceApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SalesforceApiService });
676
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SalesforceApiService, decorators: [{
677
+ type: Injectable
678
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
679
+
680
+ class DocumentTemplatesApiService {
681
+ constructor(service, salesforceApiService, fileDownloadService, documentAttachmentService, http) {
682
+ this.service = service;
683
+ this.salesforceApiService = salesforceApiService;
684
+ this.fileDownloadService = fileDownloadService;
685
+ this.documentAttachmentService = documentAttachmentService;
686
+ this.http = http;
687
+ this.DOCGEN_TAG = 'docgen';
688
+ this.SERVICE_URL = '/templates';
689
+ this.DOC_GEN_URL_FALLBACK = 'https://dev-dp1.velocpq.com/docgen';
690
+ this.mapSfQueryResult = (limit) => map((records) => {
691
+ if (!records.length) {
692
+ return { _result: 'No Records Found' };
693
+ }
694
+ if (limit === 1) {
695
+ return records[0];
696
+ }
697
+ return records;
698
+ });
699
+ this.mapBooleanIfAplicable = (value) => {
700
+ if (value === 'true') {
701
+ return true;
702
+ }
703
+ if (value === 'false') {
704
+ return false;
705
+ }
706
+ return value;
707
+ };
708
+ if (window.VELO_DOCGEN_API) {
709
+ this.DOC_GEN_URL = window.VELO_DOCGEN_API;
710
+ }
711
+ else {
712
+ console.log(`window.VELO_DOCGEN_API not set, will use fallback "${this.DOC_GEN_URL_FALLBACK}"`);
713
+ this.DOC_GEN_URL = this.DOC_GEN_URL_FALLBACK;
714
+ }
715
+ }
716
+ getTemplates(tag) {
717
+ return this.service.api({
718
+ url: `${this.SERVICE_URL}`,
719
+ method: 'get',
720
+ params: {
721
+ ...(tag && { tag }),
722
+ },
723
+ });
724
+ }
725
+ getTemplate(id) {
726
+ return this.service.api({
727
+ url: `${this.SERVICE_URL}/${id}`,
728
+ method: 'get',
729
+ });
730
+ }
731
+ upsertTemplate(template, file, reportProgress) {
732
+ const formData = new FormData();
733
+ if (file) {
734
+ formData.append('file', file, file.name);
735
+ }
736
+ formData.append('template', new Blob([JSON.stringify(template)], {
737
+ type: 'application/json',
738
+ }));
739
+ let url = `${this.SERVICE_URL}`;
740
+ if (template.id) {
741
+ url += `/${template.id}`;
742
+ }
743
+ return this.service.upload({
744
+ url,
745
+ body: formData,
746
+ method: template.id ? 'put' : 'post',
747
+ reportProgress,
748
+ });
749
+ }
750
+ removeTemplate(id) {
751
+ return this.service.api({
752
+ url: `${this.SERVICE_URL}/${id}`,
753
+ method: 'delete',
754
+ });
755
+ }
756
+ restoreTemplate(id) {
757
+ return this.service.api({
758
+ url: `${this.SERVICE_URL}/${id}/restore`,
759
+ method: 'patch',
760
+ });
761
+ }
762
+ cloneTemplate(id, propertiesToOverride = {}) {
763
+ return this.service.api({
764
+ url: `${this.SERVICE_URL}/clone/${id}`,
765
+ method: 'post',
766
+ body: {
767
+ id,
768
+ propertiesToOverride,
769
+ },
770
+ });
771
+ }
772
+ getTemplateFile(id) {
773
+ return this.service.api({
774
+ method: 'get',
775
+ url: `${this.SERVICE_URL}/${id}/file`,
776
+ responseType: 'arraybuffer',
777
+ });
778
+ }
779
+ downloadTemplateFile(id) {
780
+ return this.service
781
+ .api({
782
+ url: `${this.SERVICE_URL}/${id}/file`,
783
+ responseType: 'blob',
784
+ observe: 'response',
785
+ })
786
+ .pipe(tap(response => {
787
+ this.fileDownloadService.processDownload(response);
788
+ }), map(response => response.body || response));
789
+ }
790
+ mergeDocuments(document, attachments) {
791
+ const body = new FormData();
792
+ attachments.forEach(attachment => {
793
+ body.append('attachments', new Blob([attachment]));
794
+ });
795
+ body.append('orderform', document);
796
+ return this.http.post(`${this.DOC_GEN_URL}/documents/merge`, body, {
797
+ responseType: 'arraybuffer',
798
+ });
799
+ }
800
+ getAttachments(searchRequest) {
801
+ return this.documentAttachmentService.getAttachments(searchRequest);
802
+ }
803
+ getAttachmentFile(id) {
804
+ return this.documentAttachmentService.getAttachmentFile(id);
805
+ }
806
+ createAttachment(attachment, file, reportProgress) {
807
+ return this.documentAttachmentService.createAttachment(attachment, file, reportProgress);
808
+ }
809
+ removeAttachment(id) {
810
+ return this.documentAttachmentService.removeAttachment(id);
811
+ }
812
+ generateDocumentData(template, object, params = {}) {
813
+ if (isLegacyDocumentTemplate(template)) {
814
+ return this.generateDocumentDataLegacy(template, object, params);
815
+ }
816
+ const templateProperties = template.properties?.reduce((acc, { name, value }) => ({ ...acc, [name]: this.mapBooleanIfAplicable(value) }), {});
817
+ /*
818
+ Resolve quote and template properties for now
819
+ When procedures are ready, whey will replace template scripts.
820
+
821
+ TODO: run procedure to resolve document data
822
+ */
823
+ return of({
824
+ ...(typeof object === 'object' ? object : { object }),
825
+ ...templateProperties,
826
+ });
827
+ }
828
+ generateDocument(template, object, params = {}) {
829
+ const documentData$ = this.generateDocumentData(template, object, { ...params, shouldPreventDownload: true });
830
+ return zip(this.getTemplateFile(template.id), documentData$, this.resolveAttachments$(template)).pipe(switchMap(([templateFile, data, attachments]) => {
831
+ const document = DocxTemplater.generate(templateFile, data);
832
+ const properties = object?.context?.properties ?? object?.properties ?? {};
833
+ const documentName = properties['Name'] || template.name;
834
+ const documentFormat = params.documentFormat ?? template.properties?.find(p => p.name === 'documentFormat')?.value;
835
+ if (documentFormat === 'DOCX') {
836
+ this.fileDownloadService.processDownload(document, documentName);
837
+ return of(document);
838
+ }
839
+ return this.mergeDocuments(document, attachments).pipe(switchMap(pdf => {
840
+ if (params.attachToQuote && QuoteDraft.isQuote(object)) {
841
+ const file = new File([pdf], `${documentName}.pdf`);
842
+ return this.documentAttachmentService
843
+ .createAttachment({
844
+ linkedEntityId: object.quoteId,
845
+ fileName: documentName,
846
+ fileExtension: 'pdf',
847
+ tags: this.DOCGEN_TAG,
848
+ }, file)
849
+ .pipe(map(() => pdf));
850
+ }
851
+ return of(pdf);
852
+ }), map(pdf => {
853
+ const blob = new Blob([pdf]);
854
+ if (!params.shouldPreventDownload) {
855
+ this.fileDownloadService.processDownload(blob, `${documentName}.pdf`);
856
+ }
857
+ return blob;
858
+ }));
859
+ }));
860
+ }
861
+ generateDocumentDataLegacy(template, object, params = {}) {
862
+ const shouldPreventDownload = params.shouldPreventDownload;
863
+ const allQueries = [...(template?.queries ?? [])];
864
+ const properties = object?.context?.properties ?? object?.properties ?? {};
865
+ const accountId = properties?.['AccountId'];
866
+ const userId = properties?.['UserId'];
867
+ if (accountId) {
868
+ allQueries.push({
869
+ queryName: 'QuoteAccountQuery',
870
+ objectName: 'Account',
871
+ resultObjectName: 'account',
872
+ statement: `Id ='${accountId}'`,
873
+ fields: [],
874
+ });
875
+ }
876
+ if (userId) {
877
+ allQueries.push({
878
+ queryName: 'QuoteUserQuery',
879
+ objectName: 'User',
880
+ resultObjectName: 'agent',
881
+ statement: `Id ='${userId}'`,
882
+ fields: [],
883
+ });
884
+ }
885
+ const queries = allQueries.map(query => this.queryObject(query, { properties })) || [];
886
+ return forkJoin([...queries]).pipe(defaultIfEmpty([]), map(results => {
887
+ const queriesResult = _.chain(results)
888
+ .reduce((acc, r) => {
889
+ if (r) {
890
+ return { ...acc, ...r };
891
+ }
892
+ return acc;
893
+ }, {})
894
+ .value();
895
+ const templateProperties = (template?.properties || []).reduce((trunk, { name, value }) => {
896
+ return {
897
+ ...trunk,
898
+ [name]: this.mapBooleanIfAplicable(value),
899
+ };
900
+ }, {});
901
+ const data = {
902
+ ...(typeof object === 'object' ? object : { object }),
903
+ ...queriesResult,
904
+ ...templateProperties,
905
+ };
906
+ if (template.script && template.script.trim().length) {
907
+ const currencyFormat = template.properties?.find(({ name }) => name === 'currencyFormat')?.value || '1.2-2';
908
+ const dateFormat = template.properties?.find(({ name }) => name === 'dateFormat')?.value || 'D/MMM/YYYY';
909
+ const formatDate = (value) => {
910
+ return value ? moment(value).format(dateFormat) : value;
911
+ };
912
+ const transform = new Function(`return ${template.script}`)();
913
+ const transformedData = transform({
914
+ ...data,
915
+ utils: {
916
+ lodash: _,
917
+ currency: (value) => new CurrencyPipe('en-US').transform(value, 'USD', 'symbol', currencyFormat),
918
+ date: formatDate,
919
+ },
920
+ ToDay: formatDate(Date.now()),
921
+ });
922
+ if (!shouldPreventDownload) {
923
+ const blob = new Blob([JSON.stringify(transformedData)]);
924
+ this.fileDownloadService.processDownload(blob, 'data.json');
925
+ }
926
+ return transformedData;
927
+ }
928
+ return data;
929
+ }));
930
+ }
931
+ resolveAttachments$(template) {
932
+ const attachmentIds = template.attachments?.map(({ id }) => id).filter(Boolean) ?? [];
933
+ if (!attachmentIds.length) {
934
+ return of([]);
935
+ }
936
+ return forkJoin(attachmentIds.map(id => this.documentAttachmentService.getAttachmentFile(id, true)));
937
+ }
938
+ queryObject({ objectName, resultObjectName, fields, statement }, { properties }) {
939
+ const patternLimit = /(\s*limit\s\d*)/i;
940
+ let limit = 1;
941
+ if (statement && patternLimit.test(statement)) {
942
+ const limitStr = statement?.match(patternLimit)?.[1].trim().substring(5).trim();
943
+ if (limitStr) {
944
+ limit = Number.parseInt(limitStr, 10);
945
+ }
946
+ statement = statement.replace(patternLimit, '');
947
+ }
948
+ const resolvedStatement = statement
949
+ ? StringUtils.fillPlaceholders(statement, properties, /:\s*(\w[\w\d_.]+)/i)
950
+ : undefined;
951
+ const searchRequest = {
952
+ skip: 0,
953
+ count: limit,
954
+ rawCondition: resolvedStatement,
955
+ ...(fields?.length && !!fields[0] && { fields }),
956
+ };
957
+ return this.salesforceApiService.query(searchRequest, objectName).pipe(this.mapSfQueryResult(limit), map(value => ({ [resultObjectName]: value })));
958
+ }
959
+ }
960
+ DocumentTemplatesApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DocumentTemplatesApiService, deps: [{ token: i1.BaseHttpService }, { token: SalesforceApiService }, { token: i1.FileDownloadService }, { token: DocumentAttachmentApiService }, { token: i4.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
961
+ DocumentTemplatesApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DocumentTemplatesApiService });
962
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DocumentTemplatesApiService, decorators: [{
963
+ type: Injectable
964
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }, { type: SalesforceApiService }, { type: i1.FileDownloadService }, { type: DocumentAttachmentApiService }, { type: i4.HttpClient }]; } });
965
+
966
+ class EndpointsApiService {
967
+ constructor(baseHttpService) {
968
+ this.baseHttpService = baseHttpService;
969
+ this.adminServiceUrl = '/admin/api-endpoints';
970
+ this.serviceUrl = '/api-endpoints';
971
+ }
972
+ fetchEndpoints$() {
973
+ return this.searchEndpoints$(new Expression(), 0, -1);
974
+ }
975
+ searchEndpoints$(expression, skip, count) {
976
+ let params = new HttpParams();
977
+ params = params.set('skip', '' + skip);
978
+ params = params.set('count', '' + count);
979
+ return this.baseHttpService.api({
980
+ method: 'post',
981
+ url: `${this.adminServiceUrl}/search`,
982
+ params,
983
+ body: expression,
984
+ });
985
+ }
986
+ removeEndpoint$(id) {
987
+ return this.baseHttpService.api({
988
+ url: `${this.adminServiceUrl}/${id}`,
989
+ method: 'delete',
990
+ });
991
+ }
992
+ restoreEndpoint$(id) {
993
+ return this.baseHttpService.api({
994
+ url: `${this.adminServiceUrl}/${id}/restore`,
995
+ method: 'patch',
996
+ });
997
+ }
998
+ fetchEndpoint$(id) {
999
+ return this.baseHttpService.api({
1000
+ url: `${this.adminServiceUrl}/${id}`,
1001
+ method: 'get',
1002
+ });
1003
+ }
1004
+ createEndpoint$(body) {
1005
+ return this.baseHttpService.api({
1006
+ url: `${this.adminServiceUrl}`,
1007
+ method: 'post',
1008
+ body,
1009
+ });
1010
+ }
1011
+ updateEndpoint$(body) {
1012
+ return this.baseHttpService.api({
1013
+ url: `${this.adminServiceUrl}/${body.id}`,
1014
+ method: 'put',
1015
+ body,
1016
+ });
1017
+ }
1018
+ duplicateEndpoint$(cloneRequest) {
1019
+ return this.baseHttpService.api({
1020
+ url: `${this.adminServiceUrl}/${cloneRequest.id}/clone`,
1021
+ method: 'post',
1022
+ body: cloneRequest,
1023
+ });
1024
+ }
1025
+ executeEndpoint$(body) {
1026
+ return this.baseHttpService.api({
1027
+ url: `${this.serviceUrl}/execute`,
1028
+ method: 'post',
1029
+ body,
1030
+ responseType: 'text',
1031
+ skipErrorHandler: true,
1032
+ });
1033
+ }
1034
+ }
1035
+ EndpointsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: EndpointsApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1036
+ EndpointsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: EndpointsApiService });
1037
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: EndpointsApiService, decorators: [{
1038
+ type: Injectable
1039
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1040
+
1041
+ class FlowsApiService {
1042
+ constructor(configurationSettingsApiService) {
1043
+ this.configurationSettingsApiService = configurationSettingsApiService;
1044
+ this.flowsKey = 'flows';
1045
+ }
1046
+ getFlow(id) {
1047
+ return this.fetchFlows().pipe(map(flows => flows.find(flow => flow.id == id)));
1048
+ }
1049
+ fetchFlows() {
1050
+ return this.configurationSettingsApiService
1051
+ .fetchSetting(this.flowsKey)
1052
+ .pipe(map((flow) => (flow?.value ? JSON.parse(flow.value) : [])));
1053
+ }
1054
+ }
1055
+ FlowsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowsApiService, deps: [{ token: ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1056
+ FlowsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowsApiService });
1057
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowsApiService, decorators: [{
1058
+ type: Injectable
1059
+ }], ctorParameters: function () { return [{ type: ConfigurationSettingsApiService }]; } });
1060
+
1061
+ class GuidedSellingsAdminApiService {
1062
+ constructor(baseHttpService) {
1063
+ this.baseHttpService = baseHttpService;
1064
+ this.serviceUrl = '/admin/guided-selling';
1065
+ this.fetchGuidedSellings$ = (searchParams) => {
1066
+ return this.searchGuidedSellings$(searchParams);
1067
+ };
1068
+ this.searchGuidedSellings$ = (searchParams, expression) => {
1069
+ const params = new HttpParams({ fromObject: { ...searchParams } });
1070
+ return this.baseHttpService.api({
1071
+ method: 'post',
1072
+ url: `${this.serviceUrl}/search`,
1073
+ params,
1074
+ body: expression || {},
1075
+ });
1076
+ };
1077
+ this.fetchGuidedSelling$ = (id) => {
1078
+ return this.baseHttpService.api({ url: `${this.serviceUrl}/${id}` });
1079
+ };
1080
+ this.createNewGuidedSelling$ = (guidedSelling) => {
1081
+ return this.baseHttpService.api({
1082
+ url: `${this.serviceUrl}`,
1083
+ method: 'post',
1084
+ body: guidedSelling,
1085
+ });
1086
+ };
1087
+ this.duplicateGuidedSelling$ = (cloneRequest) => {
1088
+ return this.baseHttpService.api({
1089
+ url: `${this.serviceUrl}/${cloneRequest.id}/clone`,
1090
+ method: 'post',
1091
+ body: cloneRequest,
1092
+ });
1093
+ };
1094
+ this.updateGuidedSelling$ = (data) => {
1095
+ return this.baseHttpService.api({
1096
+ url: `${this.serviceUrl}/${data.id}`,
1097
+ method: 'put',
1098
+ body: data,
1099
+ });
1100
+ };
1101
+ this.removeGuidedSelling$ = (id) => {
1102
+ return this.baseHttpService.api({
1103
+ url: `${this.serviceUrl}/${id}`,
1104
+ method: 'delete',
1105
+ });
1106
+ };
1107
+ this.restoreGuidedSelling$ = (id) => {
1108
+ return this.baseHttpService.api({
1109
+ url: `${this.serviceUrl}/${id}/restore`,
1110
+ method: 'patch',
1111
+ });
1112
+ };
1113
+ }
1114
+ }
1115
+ GuidedSellingsAdminApiService.MAX_RESULTS = 60;
1116
+ GuidedSellingsAdminApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: GuidedSellingsAdminApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1117
+ GuidedSellingsAdminApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: GuidedSellingsAdminApiService });
1118
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: GuidedSellingsAdminApiService, decorators: [{
1119
+ type: Injectable
1120
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1121
+
1122
+ class GuidedSellingApiService {
1123
+ constructor(http) {
1124
+ this.http = http;
1125
+ this.serviceUrl = '/guided-selling';
1126
+ }
1127
+ searchByName$(name, searchParams) {
1128
+ const params = new HttpParams({ fromObject: { ...searchParams } });
1129
+ const expression = new Expression(undefined, [{ key: 'name', operator: Operator.EQ, value: name }]);
1130
+ return this.http.api({
1131
+ method: 'post',
1132
+ url: `${this.serviceUrl}/search`,
1133
+ params,
1134
+ body: expression || {},
1135
+ });
1136
+ }
1137
+ }
1138
+ GuidedSellingApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: GuidedSellingApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1139
+ GuidedSellingApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: GuidedSellingApiService });
1140
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: GuidedSellingApiService, decorators: [{
1141
+ type: Injectable
1142
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1143
+
1144
+ class OffersApiService {
1145
+ constructor(baseHttpService) {
1146
+ this.baseHttpService = baseHttpService;
1147
+ this.serviceUrl = '/admin/offers';
1148
+ }
1149
+ createOffer$(body) {
1150
+ return this.baseHttpService.api({
1151
+ url: `${this.serviceUrl}`,
1152
+ method: 'post',
1153
+ body,
1154
+ });
1155
+ }
1156
+ fetchOffers$() {
1157
+ return this.baseHttpService.api({
1158
+ url: `${this.serviceUrl}`,
1159
+ });
1160
+ }
1161
+ fetchOffer$(id) {
1162
+ return this.baseHttpService.api({
1163
+ url: `${this.serviceUrl}/${id}`,
1164
+ });
1165
+ }
1166
+ updateOffer$(offer) {
1167
+ return this.baseHttpService.api({
1168
+ url: `${this.serviceUrl}/${offer.id}`,
1169
+ method: 'put',
1170
+ body: offer,
1171
+ });
1172
+ }
1173
+ removeOffer$(id) {
1174
+ return this.baseHttpService.api({
1175
+ url: `${this.serviceUrl}/${id}`,
1176
+ method: 'delete',
1177
+ });
1178
+ }
1179
+ searchOffers$(expression, skip, count) {
1180
+ let params = new HttpParams();
1181
+ params = params.set('skip', '' + skip);
1182
+ params = params.set('count', '' + count);
1183
+ return this.baseHttpService.api({
1184
+ method: 'post',
1185
+ url: `${this.serviceUrl}/search`,
1186
+ params,
1187
+ body: expression,
1188
+ });
1189
+ }
1190
+ fetchOfferProducts$(id) {
1191
+ return this.baseHttpService
1192
+ .api({
1193
+ url: `${this.serviceUrl}/${id}/products`,
1194
+ })
1195
+ .pipe(map$1(response => response.products));
1196
+ }
1197
+ upsertOfferProducts$(id, products) {
1198
+ const request = { products };
1199
+ return this.baseHttpService
1200
+ .api({
1201
+ url: `${this.serviceUrl}/${id}/products`,
1202
+ method: 'put',
1203
+ body: request,
1204
+ })
1205
+ .pipe(map$1(response => response.products));
1206
+ }
1207
+ }
1208
+ OffersApiService.MAX_RESULTS = 60;
1209
+ OffersApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: OffersApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1210
+ OffersApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: OffersApiService });
1211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: OffersApiService, decorators: [{
1212
+ type: Injectable
1213
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1214
+
1215
+ class OrgInfoApiService {
1216
+ constructor(http) {
1217
+ this.http = http;
1218
+ this.CANVAS_URL_FALLBACK = 'https://canvas.velocpq.com';
1219
+ this.hostUrl = window.VELO_CANVAS_API ?? this.CANVAS_URL_FALLBACK;
1220
+ }
1221
+ getOrgInfo$(organizationId) {
1222
+ return this.http.get(`${this.hostUrl}/org-info/${organizationId}`);
1223
+ }
1224
+ }
1225
+ OrgInfoApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: OrgInfoApiService, deps: [{ token: i4.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1226
+ OrgInfoApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: OrgInfoApiService });
1227
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: OrgInfoApiService, decorators: [{
1228
+ type: Injectable
1229
+ }], ctorParameters: function () { return [{ type: i4.HttpClient }]; } });
1230
+
1231
+ class PicklistsApiService {
1232
+ constructor(baseHttpService) {
1233
+ this.baseHttpService = baseHttpService;
1234
+ this.serviceUrl = '/admin';
1235
+ this.fetchAllPicklists$ = () => this.baseHttpService.api({ url: `${this.serviceUrl}/picklists` });
1236
+ this.fetchPicklist$ = (code) => this.baseHttpService.api({ url: `${this.serviceUrl}/picklists/${code}` });
1237
+ this.createPicklist$ = (picklist) => {
1238
+ return this.baseHttpService.api({ method: 'post', url: `${this.serviceUrl}/picklists`, body: picklist });
1239
+ };
1240
+ this.updatePicklist$ = (picklist) => {
1241
+ return this.baseHttpService.api({
1242
+ method: 'put',
1243
+ url: `${this.serviceUrl}/picklists/${picklist.id}`,
1244
+ body: picklist,
1245
+ });
1246
+ };
1247
+ this.removePicklist$ = (id) => this.baseHttpService.api({ method: 'delete', url: `${this.serviceUrl}/picklists/${id}` });
1248
+ this.restorePicklist$ = (id) => {
1249
+ return this.baseHttpService.api({
1250
+ url: `${this.serviceUrl}/picklists/${id}/restore`,
1251
+ method: 'patch',
1252
+ });
1253
+ };
1254
+ this.addPicklistValue$ = (picklist, value) => {
1255
+ const data = {
1256
+ ...picklist,
1257
+ values: [...picklist.values, value],
1258
+ };
1259
+ return this.baseHttpService.api({ method: 'put', url: `${this.serviceUrl}/picklists/${picklist.id}`, body: data });
1260
+ };
1261
+ }
1262
+ }
1263
+ PicklistsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PicklistsApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1264
+ PicklistsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PicklistsApiService });
1265
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PicklistsApiService, decorators: [{
1266
+ type: Injectable
1267
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1268
+
1269
+ class PriceApiService {
1270
+ constructor(httpService) {
1271
+ this.httpService = httpService;
1272
+ this.SERVICE_URL = '/price';
1273
+ }
1274
+ calculate(request) {
1275
+ return this.httpService.api({
1276
+ method: 'post',
1277
+ url: `${this.SERVICE_URL}/calculate`,
1278
+ body: request,
1279
+ skipErrorHandler: true,
1280
+ });
1281
+ }
1282
+ getPriceLists() {
1283
+ return this.httpService.api({
1284
+ method: 'get',
1285
+ url: '/price-lists',
1286
+ });
1287
+ }
1288
+ getPriceList(id) {
1289
+ return this.httpService.api({
1290
+ method: 'get',
1291
+ url: `/price-lists/${id}`,
1292
+ });
1293
+ }
1294
+ getSellingTermByEndDate(planId, offeringId, startDate, endDate, frequencyUnit, frequencyDuration) {
1295
+ return this.httpService.api({
1296
+ method: 'post',
1297
+ url: `${this.SERVICE_URL}/selling-term-by-end-date`,
1298
+ body: {
1299
+ planId: planId,
1300
+ offeringId: offeringId,
1301
+ startDate: startDate,
1302
+ endDate: endDate,
1303
+ frequencyUnit: frequencyUnit,
1304
+ frequencyDuration: frequencyDuration,
1305
+ },
1306
+ });
1307
+ }
1308
+ getSellingTermByTerm(planId, offeringId, startDate, term, frequencyUnit, frequencyDuration) {
1309
+ return this.httpService.api({
1310
+ method: 'post',
1311
+ url: `${this.SERVICE_URL}/selling-term-by-term`,
1312
+ body: {
1313
+ planId: planId,
1314
+ offeringId: offeringId,
1315
+ startDate: startDate,
1316
+ term: term,
1317
+ frequencyUnit: frequencyUnit,
1318
+ frequencyDuration: frequencyDuration,
1319
+ },
1320
+ });
1321
+ }
1322
+ }
1323
+ PriceApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PriceApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1324
+ PriceApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PriceApiService });
1325
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PriceApiService, decorators: [{
1326
+ type: Injectable
1327
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1328
+
1329
+ class ProceduresApiService {
1330
+ constructor(baseHttpService) {
1331
+ this.baseHttpService = baseHttpService;
1332
+ this.ADMIN_SERVICE_URL = '/admin/procedures';
1333
+ this.SERVICE_URL = '/procedures';
1334
+ this.fetchProcedures$ = () => {
1335
+ return this.searchProcedures$(new Expression(), 0, 100);
1336
+ };
1337
+ this.searchProcedures$ = (expression, skip, count) => {
1338
+ let params = new HttpParams();
1339
+ params = params.set('skip', '' + skip);
1340
+ params = params.set('count', '' + count);
1341
+ return this.baseHttpService.api({
1342
+ method: 'post',
1343
+ url: `${this.ADMIN_SERVICE_URL}/search`,
1344
+ params,
1345
+ body: expression,
1346
+ });
1347
+ };
1348
+ this.createProcedure$ = (newProcedure) => {
1349
+ return this.baseHttpService.api({
1350
+ url: `${this.ADMIN_SERVICE_URL}`,
1351
+ method: 'post',
1352
+ body: newProcedure,
1353
+ });
1354
+ };
1355
+ this.updateProcedure$ = (procedure) => {
1356
+ return this.baseHttpService.api({
1357
+ url: `${this.ADMIN_SERVICE_URL}/${procedure.id}`,
1358
+ method: 'put',
1359
+ body: procedure,
1360
+ });
1361
+ };
1362
+ this.duplicateProcedure$ = (body) => {
1363
+ return this.baseHttpService
1364
+ .api({
1365
+ url: `${this.ADMIN_SERVICE_URL}/${body.id}/clone`,
1366
+ method: 'post',
1367
+ body,
1368
+ })
1369
+ .pipe(map(response => response.clonedRecordId));
1370
+ };
1371
+ this.removeProcedure$ = (id) => {
1372
+ return this.baseHttpService.api({
1373
+ url: `${this.ADMIN_SERVICE_URL}/${id}`,
1374
+ method: 'delete',
1375
+ });
1376
+ };
1377
+ this.restoreProcedure$ = (id) => {
1378
+ return this.baseHttpService.api({
1379
+ url: `${this.ADMIN_SERVICE_URL}/${id}/restore`,
1380
+ method: 'patch',
1381
+ });
1382
+ };
1383
+ }
1384
+ fetchProcedure$(id) {
1385
+ return this.baseHttpService.api({
1386
+ url: `${this.ADMIN_SERVICE_URL}/${id}`,
1387
+ method: 'get',
1388
+ });
1389
+ }
1390
+ execute$(body) {
1391
+ return this.baseHttpService.api({
1392
+ url: `${this.SERVICE_URL}/execute`,
1393
+ method: 'post',
1394
+ body,
1395
+ });
1396
+ }
1397
+ /**
1398
+ * Run active procedure against QuoteDraft
1399
+ * @param body
1400
+ * @returns
1401
+ */
1402
+ apply$(body) {
1403
+ return this.baseHttpService.api({
1404
+ url: `${this.SERVICE_URL}/apply`,
1405
+ method: 'post',
1406
+ body,
1407
+ });
1408
+ }
1409
+ }
1410
+ ProceduresApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProceduresApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1411
+ ProceduresApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProceduresApiService });
1412
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProceduresApiService, decorators: [{
1413
+ type: Injectable
1414
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1415
+
1416
+ class ProductApiService {
1417
+ constructor(baseHttpService) {
1418
+ this.baseHttpService = baseHttpService;
1419
+ this.serviceUrl = '/products';
1420
+ this.fetchProducts$ = (payload) => {
1421
+ let params = new HttpParams();
1422
+ params = params.append('count', payload.count);
1423
+ params = params.append('skip', payload.skip);
1424
+ if (payload.name) {
1425
+ params = params.append('name', payload.name);
1426
+ }
1427
+ return this.baseHttpService.api({ url: `${this.serviceUrl}`, params });
1428
+ };
1429
+ this.searchProducts$ = (expression, skip, count) => {
1430
+ let params = new HttpParams();
1431
+ params = params.set('skip', '' + skip);
1432
+ params = params.set('count', '' + count);
1433
+ return this.baseHttpService.api({
1434
+ method: 'post',
1435
+ url: `${this.serviceUrl}/search`,
1436
+ params: params,
1437
+ body: expression,
1438
+ });
1439
+ };
1440
+ this.fetchProduct$ = (id) => this.baseHttpService.api({ url: `${this.serviceUrl}/${id}` });
1441
+ this.fetchAttributes$ = () => {
1442
+ return this.baseHttpService.api({ url: `${this.serviceUrl}/attributes/definition` });
1443
+ };
1444
+ this.searchAttributes$ = (expression, skip, count) => {
1445
+ let params = new HttpParams();
1446
+ params = params.set('skip', '' + skip);
1447
+ params = params.set('count', '' + count);
1448
+ return this.baseHttpService.api({
1449
+ method: 'post',
1450
+ url: `${this.serviceUrl}/attributes/definition/search`,
1451
+ params: params,
1452
+ body: expression,
1453
+ });
1454
+ };
1455
+ this.fetchAttributesByModel = (modelId) => {
1456
+ return this.baseHttpService.api({ url: `${this.serviceUrl}/attributes/definition/forModel/${modelId}` });
1457
+ };
1458
+ this.createNewProduct$ = (productData) => {
1459
+ return this.baseHttpService.api({
1460
+ url: `${this.serviceUrl}`,
1461
+ method: 'post',
1462
+ body: productData,
1463
+ });
1464
+ };
1465
+ this.updateProduct$ = (body) => {
1466
+ return this.baseHttpService.api({
1467
+ url: `${this.serviceUrl}/${body.id}`,
1468
+ method: 'put',
1469
+ body,
1470
+ });
1471
+ };
1472
+ this.removeProduct$ = (id) => {
1473
+ return this.baseHttpService.api({
1474
+ url: `${this.serviceUrl}/${id}`,
1475
+ method: 'delete',
1476
+ });
1477
+ };
1478
+ this.restoreProduct$ = (id) => {
1479
+ return this.baseHttpService.api({
1480
+ url: `${this.serviceUrl}/${id}/restore`,
1481
+ method: 'patch',
1482
+ });
1483
+ };
1484
+ this.createProductAttribute$ = (attributeData) => {
1485
+ return this.baseHttpService.api({
1486
+ url: `${this.serviceUrl}/attributes`,
1487
+ method: 'post',
1488
+ body: attributeData,
1489
+ });
1490
+ };
1491
+ this.updateProductAttribute$ = (attributeData) => {
1492
+ return this.baseHttpService.api({
1493
+ url: `${this.serviceUrl}/attributes/${attributeData.id}`,
1494
+ method: 'put',
1495
+ body: attributeData,
1496
+ });
1497
+ };
1498
+ this.removeProductAttribute$ = (id) => {
1499
+ return this.baseHttpService.api({
1500
+ url: `${this.serviceUrl}/attributes/${id}`,
1501
+ method: 'delete',
1502
+ });
1503
+ };
1504
+ this.createNewAttribute$ = (attributeData) => {
1505
+ return this.baseHttpService.api({
1506
+ url: `${this.serviceUrl}/attributes/definition`,
1507
+ method: 'post',
1508
+ body: attributeData,
1509
+ });
1510
+ };
1511
+ this.updateAttribute$ = (body) => {
1512
+ return this.baseHttpService.api({
1513
+ url: `${this.serviceUrl}/attributes/definition/${body.id}`,
1514
+ method: 'put',
1515
+ body,
1516
+ });
1517
+ };
1518
+ this.removeAttribute$ = (id) => {
1519
+ return this.baseHttpService.api({
1520
+ url: `${this.serviceUrl}/attributes/definition/${id}`,
1521
+ method: 'delete',
1522
+ });
1523
+ };
1524
+ this.restoreAttribute$ = (id) => {
1525
+ return this.baseHttpService.api({
1526
+ url: `${this.serviceUrl}/attributes/definition/${id}/restore`,
1527
+ method: 'patch',
1528
+ });
1529
+ };
1530
+ }
1531
+ attachImage$(productId, file) {
1532
+ const data = new FormData();
1533
+ data.append('image', file);
1534
+ return this.baseHttpService.upload({
1535
+ method: 'post',
1536
+ url: `${this.serviceUrl}/${productId}/image`,
1537
+ body: data,
1538
+ });
1539
+ }
1540
+ removeImage$(productId) {
1541
+ return this.baseHttpService.api({
1542
+ method: 'delete',
1543
+ url: `${this.serviceUrl}/${productId}/image`,
1544
+ });
1545
+ }
1546
+ fetchImage$(productId) {
1547
+ return this.baseHttpService.api({
1548
+ url: this.getImageUrl(productId),
1549
+ method: 'get',
1550
+ responseType: 'blob',
1551
+ errorHandler: noop,
1552
+ });
1553
+ }
1554
+ getImageUrl(productId) {
1555
+ return `${this.serviceUrl}/${productId}/image`;
1556
+ }
1557
+ }
1558
+ ProductApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1559
+ ProductApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductApiService });
1560
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductApiService, decorators: [{
1561
+ type: Injectable
1562
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1563
+
1564
+ class ProductModelApiService {
1565
+ constructor(httpService) {
1566
+ this.httpService = httpService;
1567
+ this.SERVICE_URL = '/models';
1568
+ }
1569
+ addModel(model) {
1570
+ return this.httpService
1571
+ .api({
1572
+ method: 'post',
1573
+ url: this.SERVICE_URL,
1574
+ body: model,
1575
+ errorHandler: this.httpService.handleValidationError,
1576
+ })
1577
+ .pipe(map(result => {
1578
+ if (result.successful) {
1579
+ return result;
1580
+ }
1581
+ else {
1582
+ throw new Error(result.message);
1583
+ }
1584
+ }));
1585
+ }
1586
+ releaseModel(model) {
1587
+ return this.httpService
1588
+ .api({
1589
+ method: 'put',
1590
+ url: `${this.SERVICE_URL}/${model.id}/release`,
1591
+ body: model,
1592
+ errorHandler: this.httpService.handleValidationError,
1593
+ })
1594
+ .pipe(map(result => {
1595
+ if (result.successful) {
1596
+ return '';
1597
+ }
1598
+ else {
1599
+ throw new Error(result.message);
1600
+ }
1601
+ }));
1602
+ }
1603
+ removeModel(modelId, successFn, failureFn) {
1604
+ const observable = this.httpService
1605
+ .api({
1606
+ method: 'delete',
1607
+ url: `${this.SERVICE_URL}/${modelId}`,
1608
+ errorHandler: this.httpService.handleValidationError,
1609
+ })
1610
+ .pipe(map(result => {
1611
+ if (result.successful) {
1612
+ return '';
1613
+ }
1614
+ else {
1615
+ throw new Error(result.message);
1616
+ }
1617
+ }));
1618
+ observable.subscribe(() => {
1619
+ successFn && successFn.apply();
1620
+ }, () => {
1621
+ failureFn && failureFn.apply();
1622
+ });
1623
+ }
1624
+ getModelVersions(modelId, count = 100, skip = 0) {
1625
+ return this.httpService.api({
1626
+ method: 'post',
1627
+ url: `${this.SERVICE_URL}/${modelId}/versions`,
1628
+ body: {
1629
+ skipCount: skip,
1630
+ count: count,
1631
+ },
1632
+ });
1633
+ }
1634
+ getModel(id, version) {
1635
+ let url = `${this.SERVICE_URL}/${id}`;
1636
+ if (version) {
1637
+ url += `/versions/${version}`;
1638
+ }
1639
+ return this.httpService.api({ url });
1640
+ }
1641
+ getModels(skipCount, searchText) {
1642
+ return this.httpService.api({
1643
+ method: 'post',
1644
+ url: `${this.SERVICE_URL}/search`,
1645
+ body: {
1646
+ nameRegex: searchText,
1647
+ skipCount: skipCount.toString(),
1648
+ count: ProductModelApiService.MAX_RESULTS,
1649
+ },
1650
+ });
1651
+ }
1652
+ getLinkedModels(id, version) {
1653
+ let url = `${this.SERVICE_URL}/${id}`;
1654
+ if (version) {
1655
+ url += `/versions/${version}`;
1656
+ }
1657
+ url += '/linked';
1658
+ return this.httpService.api({ url }).pipe(map((linkedModels) => {
1659
+ if (linkedModels) {
1660
+ linkedModels.forEach(model => ModelTranslatorUtils.toLocalModel(model));
1661
+ }
1662
+ return linkedModels;
1663
+ }));
1664
+ }
1665
+ load(id, version) {
1666
+ return forkJoin([this.getModel(id, version), this.getLinkedModels(id, version)]).pipe(map(([model, linkedModels]) => {
1667
+ const container = new ProductModelsContainer(model, linkedModels ?? []);
1668
+ ModelUtils.override(container.main, container.linked);
1669
+ ModelTranslatorUtils.toLocalModel(container.main, container.linked);
1670
+ return container;
1671
+ }));
1672
+ }
1673
+ getPML(modelId, version) {
1674
+ let url = `${this.SERVICE_URL}/${modelId}/pml/${version}`;
1675
+ if (version) {
1676
+ url += `/versions/${version}`;
1677
+ }
1678
+ return this.httpService.api({
1679
+ url,
1680
+ responseType: 'text',
1681
+ });
1682
+ }
1683
+ savePML(modelId, pml, comment) {
1684
+ return this.httpService
1685
+ .api({
1686
+ method: 'put',
1687
+ url: `${this.SERVICE_URL}/${modelId}/pml`,
1688
+ body: {
1689
+ id: modelId,
1690
+ pml: pml,
1691
+ comment: comment,
1692
+ },
1693
+ })
1694
+ .pipe(map(result => {
1695
+ if (result.successful) {
1696
+ return '';
1697
+ }
1698
+ else {
1699
+ throw new Error(result.message);
1700
+ }
1701
+ }), catchError(this.httpService.handleValidationError));
1702
+ }
1703
+ generateProducts(modelId) {
1704
+ return this.httpService.api({
1705
+ url: `${this.SERVICE_URL}/${modelId}/generate-products`,
1706
+ });
1707
+ }
1708
+ saveModel(productModel, comment) {
1709
+ const model = EntityUtil.clone(productModel);
1710
+ model.comment = comment;
1711
+ ModelTranslatorUtils.toServerModel(model);
1712
+ return this.httpService
1713
+ .api({
1714
+ method: 'put',
1715
+ url: `${this.SERVICE_URL}/${model.id}`,
1716
+ body: model,
1717
+ })
1718
+ .pipe(map(result => {
1719
+ if (result.successful) {
1720
+ return '';
1721
+ }
1722
+ else {
1723
+ throw new Error(result.message);
1724
+ }
1725
+ }), catchError(this.httpService.handleValidationError));
1726
+ }
1727
+ validateModel(productModel) {
1728
+ return this.httpService
1729
+ .api({
1730
+ method: 'post',
1731
+ url: `${this.SERVICE_URL}/validate`,
1732
+ body: productModel,
1733
+ errorHandler: this.httpService.handleValidationError,
1734
+ })
1735
+ .pipe(map(result => {
1736
+ if (result.successful) {
1737
+ return '';
1738
+ }
1739
+ else {
1740
+ throw new Error(result.message);
1741
+ }
1742
+ }));
1743
+ }
1744
+ renameModel(productModel, name) {
1745
+ const model = EntityUtil.clone(productModel);
1746
+ model.name = name;
1747
+ ModelTranslatorUtils.toServerModel(model);
1748
+ return this.httpService
1749
+ .api({
1750
+ method: 'patch',
1751
+ url: `${this.SERVICE_URL}/${model.id}`,
1752
+ body: model,
1753
+ })
1754
+ .pipe(catchError(this.httpService.handleValidationError));
1755
+ }
1756
+ uploadPmlFile(file, modelId) {
1757
+ const formData = new FormData();
1758
+ formData.append('file', file, file.name);
1759
+ return this.httpService.upload({
1760
+ url: `${this.SERVICE_URL}/${modelId}/pml/upload`,
1761
+ body: formData,
1762
+ });
1763
+ }
1764
+ runPml(modelId, pml, rootType, configurationMode) {
1765
+ return this.httpService.api({
1766
+ method: 'post',
1767
+ url: `${this.SERVICE_URL}/${modelId}/pml/run`,
1768
+ body: {
1769
+ pml,
1770
+ rootType,
1771
+ configurationMode,
1772
+ },
1773
+ responseType: 'text',
1774
+ });
1775
+ }
1776
+ evictAllCache() {
1777
+ return this.httpService.api({
1778
+ method: 'get',
1779
+ url: '/cache/evict/environment-variables',
1780
+ });
1781
+ }
1782
+ }
1783
+ ProductModelApiService.MAX_RESULTS = 200;
1784
+ ProductModelApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductModelApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1785
+ ProductModelApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductModelApiService });
1786
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductModelApiService, decorators: [{
1787
+ type: Injectable
1788
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1789
+
1790
+ class QuoteApiService {
1791
+ constructor(httpService) {
1792
+ this.httpService = httpService;
1793
+ this.SERVICE_URL = '/quotes';
1794
+ /**
1795
+ * @deprecated
1796
+ * Will be removed in next major release
1797
+ * Use `getQuoteDraft` instead
1798
+ */
1799
+ // eslint-disable-next-line @typescript-eslint/member-ordering
1800
+ this.getQuote = this.getQuoteDraft;
1801
+ }
1802
+ // request quoteId | accountId | opportunityId | orderId
1803
+ getQuoteDraft(objectId, params, errorHandler) {
1804
+ return this.httpService.api({
1805
+ method: 'get',
1806
+ url: `${this.SERVICE_URL}/${objectId}`,
1807
+ params,
1808
+ errorHandler,
1809
+ });
1810
+ }
1811
+ upsertQuote(request, options) {
1812
+ return this.httpService.api({
1813
+ method: 'post',
1814
+ url: `${this.SERVICE_URL}`,
1815
+ body: request,
1816
+ ...options,
1817
+ });
1818
+ }
1819
+ submitQuote(request, options) {
1820
+ return this.httpService.api({
1821
+ method: 'post',
1822
+ url: `${this.SERVICE_URL}/submit`,
1823
+ body: request,
1824
+ ...options,
1825
+ });
1826
+ }
1827
+ attachDocument(id, documentName, data) {
1828
+ const formData = new FormData();
1829
+ const blob = new Blob([data]);
1830
+ formData.append('file', blob, documentName);
1831
+ return this.httpService.upload({
1832
+ url: `${this.SERVICE_URL}/${id}/attach-document`,
1833
+ responseType: 'arraybuffer',
1834
+ method: 'post',
1835
+ body: formData,
1836
+ });
1837
+ }
1838
+ }
1839
+ QuoteApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1840
+ QuoteApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteApiService });
1841
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteApiService, decorators: [{
1842
+ type: Injectable
1843
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1844
+
1845
+ class RampApiService {
1846
+ constructor(httpService) {
1847
+ this.httpService = httpService;
1848
+ this.SERVICE_URL = '/ramp';
1849
+ }
1850
+ next(request, options) {
1851
+ return this.httpService.api({
1852
+ method: 'post',
1853
+ url: `${this.SERVICE_URL}/next`,
1854
+ body: request,
1855
+ ...options,
1856
+ });
1857
+ }
1858
+ renew(request, options) {
1859
+ return this.httpService.api({
1860
+ method: 'post',
1861
+ url: `${this.SERVICE_URL}/renew`,
1862
+ body: request,
1863
+ ...options,
1864
+ });
1865
+ }
1866
+ }
1867
+ RampApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RampApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1868
+ RampApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RampApiService });
1869
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RampApiService, decorators: [{
1870
+ type: Injectable
1871
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1872
+
1873
+ class RuleGroupsApiService {
1874
+ constructor(baseHttpService) {
1875
+ this.baseHttpService = baseHttpService;
1876
+ this.serviceUrl = '/admin/rule-groups';
1877
+ this.fetchRuleGroups$ = () => {
1878
+ return this.searchRuleGroups$(new Expression(), 0, 100);
1879
+ };
1880
+ this.searchRuleGroups$ = (expression, skip, count) => {
1881
+ let params = new HttpParams();
1882
+ params = params.set('skip', '' + skip);
1883
+ params = params.set('count', '' + count);
1884
+ return this.baseHttpService.api({ method: 'post', url: `${this.serviceUrl}/search`, params, body: expression });
1885
+ };
1886
+ this.createRuleGroup$ = (ruleGroup) => {
1887
+ return this.baseHttpService.api({
1888
+ url: `${this.serviceUrl}`,
1889
+ method: 'post',
1890
+ body: ruleGroup,
1891
+ });
1892
+ };
1893
+ this.updateRuleGroup$ = (ruleGroup) => {
1894
+ return this.baseHttpService.api({
1895
+ url: `${this.serviceUrl}/${ruleGroup.id}`,
1896
+ method: 'post',
1897
+ body: ruleGroup,
1898
+ });
1899
+ };
1900
+ this.duplicateRuleGroup$ = (body) => {
1901
+ return this.baseHttpService
1902
+ .api({
1903
+ url: `${this.serviceUrl}/${body.id}/clone`,
1904
+ method: 'post',
1905
+ body,
1906
+ })
1907
+ .pipe(map$1(response => response.clonedRecordId));
1908
+ };
1909
+ this.removeRuleGroup$ = (id) => {
1910
+ return this.baseHttpService.api({
1911
+ url: `${this.serviceUrl}/${id}`,
1912
+ method: 'delete',
1913
+ });
1914
+ };
1915
+ this.restoreRuleGroup$ = (id) => {
1916
+ return this.baseHttpService.api({
1917
+ url: `${this.serviceUrl}/${id}/restore`,
1918
+ method: 'patch',
1919
+ });
1920
+ };
1921
+ }
1922
+ }
1923
+ RuleGroupsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuleGroupsApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
1924
+ RuleGroupsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuleGroupsApiService });
1925
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuleGroupsApiService, decorators: [{
1926
+ type: Injectable
1927
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
1928
+
1929
+ class RulesApiService {
1930
+ constructor(baseHttpService) {
1931
+ this.baseHttpService = baseHttpService;
1932
+ this.serviceUrl = '/admin/rules';
1933
+ this.fetchRules$ = () => {
1934
+ return this.searchRules$(new Expression(), 0, 100);
1935
+ };
1936
+ this.searchRules$ = (expression, skip, count) => {
1937
+ let params = new HttpParams();
1938
+ params = params.set('skip', '' + skip);
1939
+ params = params.set('count', '' + count);
1940
+ return this.baseHttpService.api({ method: 'post', url: `${this.serviceUrl}/search`, params, body: expression });
1941
+ };
1942
+ this.createRule$ = (rule) => {
1943
+ return this.baseHttpService.api({
1944
+ url: `${this.serviceUrl}`,
1945
+ method: 'post',
1946
+ body: rule,
1947
+ });
1948
+ };
1949
+ this.updateRule$ = (rule) => {
1950
+ return this.baseHttpService.api({
1951
+ url: `${this.serviceUrl}/${rule.id}`,
1952
+ method: 'put',
1953
+ body: rule,
1954
+ });
1955
+ };
1956
+ this.duplicateRule$ = (body) => {
1957
+ return this.baseHttpService
1958
+ .api({
1959
+ url: `${this.serviceUrl}/${body.id}/clone`,
1960
+ method: 'post',
1961
+ body,
1962
+ })
1963
+ .pipe(map(response => response.clonedRecordId));
1964
+ };
1965
+ this.removeRule$ = (id) => {
1966
+ return this.baseHttpService.api({
1967
+ url: `${this.serviceUrl}/${id}`,
1968
+ method: 'delete',
1969
+ });
1970
+ };
1971
+ this.restoreRule$ = (id) => {
1972
+ return this.baseHttpService.api({
1973
+ url: `${this.serviceUrl}/${id}/restore`,
1974
+ method: 'patch',
1975
+ });
1976
+ };
1977
+ }
1978
+ fetchRule$(id) {
1979
+ return this.baseHttpService.api({
1980
+ url: `${this.serviceUrl}/${id}`,
1981
+ method: 'get',
1982
+ });
1983
+ }
1984
+ fetchHeaderFields$() {
1985
+ return this.baseHttpService.api({
1986
+ url: `${this.serviceUrl}/describe/Header`,
1987
+ method: 'get',
1988
+ });
1989
+ }
1990
+ execute$(body) {
1991
+ const url = body.rule.ruleGroupType === RuleGroupTypes.eligibility ? '/rules/eligibility/execute' : '/rules/execute';
1992
+ return this.baseHttpService.api({
1993
+ url,
1994
+ method: 'post',
1995
+ body,
1996
+ });
1997
+ }
1998
+ }
1999
+ RulesApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RulesApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
2000
+ RulesApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RulesApiService });
2001
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RulesApiService, decorators: [{
2002
+ type: Injectable
2003
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
2004
+
2005
+ class ScriptsApiService {
2006
+ constructor(baseHttpService) {
2007
+ this.baseHttpService = baseHttpService;
2008
+ this.serviceUrl = '/admin/scripts';
2009
+ this.fetchScripts$ = () => {
2010
+ return this.baseHttpService.api({ url: `${this.serviceUrl}` });
2011
+ };
2012
+ this.searchScripts$ = (expression, skip, count) => {
2013
+ let params = new HttpParams();
2014
+ params = params.set('skip', '' + skip);
2015
+ params = params.set('count', '' + count);
2016
+ return this.baseHttpService.api({ method: 'post', url: `${this.serviceUrl}/search`, params, body: expression });
2017
+ };
2018
+ this.fetchScript$ = (id) => {
2019
+ return this.baseHttpService.api({ url: `${this.serviceUrl}/${id}` });
2020
+ };
2021
+ this.createScript$ = (script) => {
2022
+ return this.baseHttpService.api({
2023
+ url: `${this.serviceUrl}`,
2024
+ method: 'post',
2025
+ body: script,
2026
+ });
2027
+ };
2028
+ this.updateScriptMeta$ = (script) => {
2029
+ return this.baseHttpService.api({
2030
+ url: `${this.serviceUrl}/${script.id}`,
2031
+ method: 'put',
2032
+ body: script,
2033
+ });
2034
+ };
2035
+ this.updateScriptDetails$ = (script) => {
2036
+ return this.baseHttpService.api({
2037
+ url: `${this.serviceUrl}/${script.id}`,
2038
+ method: 'put',
2039
+ body: script,
2040
+ });
2041
+ };
2042
+ this.cloneScript$ = (cloneRequest) => {
2043
+ return this.baseHttpService.api({
2044
+ url: `${this.serviceUrl}/${cloneRequest.id}/clone`,
2045
+ method: 'post',
2046
+ body: cloneRequest,
2047
+ });
2048
+ };
2049
+ this.removeScript$ = (id) => {
2050
+ return this.baseHttpService.api({
2051
+ url: `${this.serviceUrl}/${id}`,
2052
+ method: 'delete',
2053
+ });
2054
+ };
2055
+ this.restoreScript$ = (id) => {
2056
+ return this.baseHttpService.api({
2057
+ url: `${this.serviceUrl}/${id}/restore`,
2058
+ method: 'patch',
2059
+ });
2060
+ };
2061
+ this.execute$ = (body) => {
2062
+ return this.baseHttpService.api({
2063
+ url: `/scripts/execute`,
2064
+ method: 'post',
2065
+ body,
2066
+ errorHandler: () => null,
2067
+ });
2068
+ };
2069
+ }
2070
+ }
2071
+ ScriptsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ScriptsApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
2072
+ ScriptsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ScriptsApiService });
2073
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ScriptsApiService, decorators: [{
2074
+ type: Injectable
2075
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
2076
+
2077
+ class ShoppingCartSettingsApiService {
2078
+ constructor(configurationSettingsApiService) {
2079
+ this.configurationSettingsApiService = configurationSettingsApiService;
2080
+ this.shoppingCartSettingsKey = 'shopping-cart';
2081
+ }
2082
+ getSetting(id) {
2083
+ return this.fetchSettings().pipe(map((settings) => parseJsonSafely(settings?.value, [])), map(settings => settings.find(setting => setting.id == id)));
2084
+ }
2085
+ fetchSettings() {
2086
+ return this.configurationSettingsApiService.fetchSetting(this.shoppingCartSettingsKey, { skipErrorHandler: true });
2087
+ }
2088
+ getSettingsMap() {
2089
+ return this.fetchSettings().pipe(map((settings) => parseJsonSafely(settings?.value, [])), map((settings) => settings.reduce((acc, setting) => {
2090
+ return { ...acc, [setting.id]: setting.properties };
2091
+ }, {})));
2092
+ }
2093
+ }
2094
+ ShoppingCartSettingsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ShoppingCartSettingsApiService, deps: [{ token: ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
2095
+ ShoppingCartSettingsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ShoppingCartSettingsApiService });
2096
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ShoppingCartSettingsApiService, decorators: [{
2097
+ type: Injectable
2098
+ }], ctorParameters: function () { return [{ type: ConfigurationSettingsApiService }]; } });
2099
+
2100
+ const fromUIComponentStoryDTO = (dto, attachments) => {
2101
+ return {
2102
+ id: dto.id,
2103
+ name: dto.name,
2104
+ uiComponentId: dto.uiComponentId,
2105
+ description: dto.description,
2106
+ section: attachments.json,
2107
+ template: attachments.html,
2108
+ script: attachments.js,
2109
+ styles: attachments.css,
2110
+ };
2111
+ };
2112
+
2113
+ class UITemplatesApiService {
2114
+ constructor(baseHttpService) {
2115
+ this.baseHttpService = baseHttpService;
2116
+ this.serviceUrl = '/uitemplates';
2117
+ this.fetchTemplates$ = (name) => {
2118
+ let params = new HttpParams();
2119
+ if (name) {
2120
+ params = params.append('name', name);
2121
+ }
2122
+ return this.baseHttpService.api({ url: `${this.serviceUrl}`, params });
2123
+ };
2124
+ this.createTemplate$ = (template) => {
2125
+ return this.baseHttpService.api({
2126
+ method: 'post',
2127
+ url: `${this.serviceUrl}`,
2128
+ body: template,
2129
+ });
2130
+ };
2131
+ this.updateTemplate$ = (template) => {
2132
+ return this.baseHttpService.api({
2133
+ method: 'put',
2134
+ url: `${this.serviceUrl}/${template.id}`,
2135
+ body: template,
2136
+ });
2137
+ };
2138
+ this.duplicateTemplate$ = (template, cloneRequest) => {
2139
+ return this.baseHttpService
2140
+ .api({
2141
+ url: `${this.serviceUrl}/${template.id}/clone`,
2142
+ method: 'post',
2143
+ body: cloneRequest,
2144
+ })
2145
+ .pipe(map$1(response => response.clonedRecordId));
2146
+ };
2147
+ this.removeTemplate$ = (id) => {
2148
+ return this.baseHttpService.api({
2149
+ method: 'delete',
2150
+ url: `${this.serviceUrl}/${id}`,
2151
+ });
2152
+ };
2153
+ this.restoreTemplate$ = (id) => {
2154
+ return this.baseHttpService.api({
2155
+ method: 'patch',
2156
+ url: `${this.serviceUrl}/${id}`,
2157
+ });
2158
+ };
2159
+ this.searchTemplates$ = (data) => {
2160
+ return this.baseHttpService.api({
2161
+ method: 'post',
2162
+ url: `${this.serviceUrl}/search`,
2163
+ params: data.params,
2164
+ body: data.expression,
2165
+ });
2166
+ };
2167
+ this.fetchComponents$ = (templateId, name) => {
2168
+ let params = new HttpParams();
2169
+ if (name) {
2170
+ params = params.append('name', name);
2171
+ }
2172
+ return this.baseHttpService.api({
2173
+ url: `${this.serviceUrl}/${templateId}/components`,
2174
+ params,
2175
+ });
2176
+ };
2177
+ this.fetchComponent$ = (templateId, componentId) => {
2178
+ return this.baseHttpService.api({
2179
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}`,
2180
+ });
2181
+ };
2182
+ this.createComponent$ = (component) => {
2183
+ return this.baseHttpService.api({
2184
+ method: 'post',
2185
+ url: `${this.serviceUrl}/${component.uiTemplateId}/components`,
2186
+ body: component,
2187
+ });
2188
+ };
2189
+ this.updateComponent$ = (component) => {
2190
+ return this.baseHttpService.api({
2191
+ method: 'put',
2192
+ url: `${this.serviceUrl}/${component.uiTemplateId}/components/${component.id}`,
2193
+ body: component,
2194
+ });
2195
+ };
2196
+ this.duplicateComponent$ = (component, cloneRequest) => {
2197
+ return this.baseHttpService
2198
+ .api({
2199
+ url: `${this.serviceUrl}/${component.uiTemplateId}/components/${component.id}/clone`,
2200
+ method: 'post',
2201
+ body: cloneRequest,
2202
+ })
2203
+ .pipe(map$1(response => response.clonedRecordId));
2204
+ };
2205
+ this.removeComponent$ = (templateId, componentId) => {
2206
+ return this.baseHttpService.api({
2207
+ method: 'delete',
2208
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}`,
2209
+ });
2210
+ };
2211
+ this.restoreComponent$ = (templateId, componentId) => {
2212
+ return this.baseHttpService.api({
2213
+ method: 'patch',
2214
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}`,
2215
+ });
2216
+ };
2217
+ this.searchComponents$ = (templateId, data) => {
2218
+ return this.baseHttpService.api({
2219
+ method: 'post',
2220
+ url: `${this.serviceUrl}/${templateId}/components/search`,
2221
+ params: data.params,
2222
+ body: data.expression,
2223
+ });
2224
+ };
2225
+ this.fetchStoryAttachment = (templateId, componentId, storyId, type) => {
2226
+ return this.baseHttpService
2227
+ .api({
2228
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}/attachments/${type}/file`,
2229
+ responseType: 'text',
2230
+ errorHandler: noop,
2231
+ })
2232
+ .pipe(catchError$1(() => of('')));
2233
+ };
2234
+ this.convertToComponentStory$ = (templateId, componentId, storyDto) => {
2235
+ return forkJoin([
2236
+ this.fetchStoryAttachment(templateId, componentId, storyDto.id, 'html'),
2237
+ this.fetchStoryAttachment(templateId, componentId, storyDto.id, 'js'),
2238
+ this.fetchStoryAttachment(templateId, componentId, storyDto.id, 'css'),
2239
+ this.fetchStoryAttachment(templateId, componentId, storyDto.id, 'json'),
2240
+ ]).pipe(map$1(([html, js, css, json]) => ({ html, js, css, json })), map$1(attachments => fromUIComponentStoryDTO(storyDto, attachments)));
2241
+ };
2242
+ this.fetchStories$ = (templateId, componentId, name) => {
2243
+ let params = new HttpParams();
2244
+ if (name) {
2245
+ params = params.append('name', name);
2246
+ }
2247
+ return this.baseHttpService
2248
+ .api({
2249
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories`,
2250
+ params,
2251
+ })
2252
+ .pipe(switchMap$1(dtos => {
2253
+ if (!dtos.length) {
2254
+ return of([]);
2255
+ }
2256
+ return forkJoin(dtos.map(dto => this.convertToComponentStory$(templateId, componentId, dto)));
2257
+ }));
2258
+ };
2259
+ this.fetchStory$ = (templateId, componentId, storyId) => {
2260
+ return this.baseHttpService
2261
+ .api({
2262
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}`,
2263
+ })
2264
+ .pipe(switchMap$1(dto => this.convertToComponentStory$(templateId, componentId, dto)));
2265
+ };
2266
+ this.createComponentStory$ = (templateId, story) => {
2267
+ return this.baseHttpService.api({
2268
+ method: 'post',
2269
+ url: `${this.serviceUrl}/${templateId}/components/${story.uiComponentId}/stories`,
2270
+ body: story,
2271
+ });
2272
+ };
2273
+ this.updateComponentStory$ = (templateId, story) => {
2274
+ const { script, template, styles, section, ...rest } = story;
2275
+ return this.baseHttpService
2276
+ .api({
2277
+ method: 'put',
2278
+ url: `${this.serviceUrl}/${templateId}/components/${story.uiComponentId}/stories/${story.id}`,
2279
+ body: rest,
2280
+ })
2281
+ .pipe(map$1(dto => fromUIComponentStoryDTO(dto, { html: template, js: script, css: styles, json: section })));
2282
+ };
2283
+ this.duplicateComponentStory$ = (story, cloneRequest) => {
2284
+ return this.baseHttpService
2285
+ .api({
2286
+ url: `${this.serviceUrl}/${story.template}/components/${story.uiComponentId}/stories/${story.id}/clone`,
2287
+ method: 'post',
2288
+ body: cloneRequest,
2289
+ })
2290
+ .pipe(map$1(response => response.clonedRecordId));
2291
+ };
2292
+ this.deleteComponentStory$ = (templateId, componentId, storyId) => {
2293
+ return this.baseHttpService.api({
2294
+ method: 'delete',
2295
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}`,
2296
+ });
2297
+ };
2298
+ this.restoreComponentStory$ = (templateId, componentId, storyId) => {
2299
+ return this.baseHttpService.api({
2300
+ method: 'patch',
2301
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}`,
2302
+ });
2303
+ };
2304
+ this.uploadStoryAttachments$ = (templateId, componentId, storyId, attachments) => {
2305
+ const formData = new FormData();
2306
+ if (attachments.html != null) {
2307
+ formData.append('html', new Blob([attachments.html]), 'story-template.html');
2308
+ }
2309
+ if (attachments.css != null) {
2310
+ formData.append('css', new Blob([attachments.css]), 'story-styles.css');
2311
+ }
2312
+ if (attachments.js != null) {
2313
+ formData.append('js', new Blob([attachments.js]), 'story-script.js');
2314
+ }
2315
+ if (attachments.json != null) {
2316
+ formData.append('json', new Blob([attachments.json]), 'story-section.json');
2317
+ }
2318
+ return this.baseHttpService.upload({
2319
+ method: 'post',
2320
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/stories/${storyId}/attachments`,
2321
+ body: formData,
2322
+ });
2323
+ };
2324
+ this.fetchComponentAttachments$ = (templateId, component) => {
2325
+ return forkJoin([
2326
+ this.fetchComponentAttachmentFile$(templateId, component.id, 'html'),
2327
+ this.fetchComponentAttachmentFile$(templateId, component.id, 'js'),
2328
+ this.fetchComponentAttachmentFile$(templateId, component.id, 'css'),
2329
+ this.fetchComponentAttachmentFile$(templateId, component.id, 'json'),
2330
+ ]).pipe(map$1(([html, js, css, json]) => ({ html, js, css, json })));
2331
+ };
2332
+ this.fetchComponentAttachmentFile$ = (templateId, componentId, attachmentType) => {
2333
+ return this.baseHttpService
2334
+ .api({
2335
+ method: 'get',
2336
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/attachments/${attachmentType}/file`,
2337
+ responseType: 'text',
2338
+ errorHandler: noop,
2339
+ })
2340
+ .pipe(catchError$1(() => of('')));
2341
+ };
2342
+ this.uploadComponentAttachments$ = (templateId, componentId, attachments) => {
2343
+ const formData = new FormData();
2344
+ if (attachments.html != null) {
2345
+ formData.append('html', new Blob([attachments.html]), 'template.html');
2346
+ }
2347
+ if (attachments.css != null) {
2348
+ formData.append('css', new Blob([attachments.css]), 'styles.css');
2349
+ }
2350
+ if (attachments.js != null) {
2351
+ formData.append('js', new Blob([attachments.js]), 'script.js');
2352
+ }
2353
+ if (attachments.json != null) {
2354
+ formData.append('json', new Blob([attachments.json]), 'section.json');
2355
+ }
2356
+ return this.baseHttpService.upload({
2357
+ method: 'post',
2358
+ url: `${this.serviceUrl}/${templateId}/components/${componentId}/attachments`,
2359
+ body: formData,
2360
+ });
2361
+ };
2362
+ }
2363
+ getTemplateThumbnailUrl(templateId) {
2364
+ return `${this.serviceUrl}/${templateId}/thumbnail/file`;
2365
+ }
2366
+ attachTemplateThumbnail$(templateId, file) {
2367
+ const data = new FormData();
2368
+ data.append('thumb', file);
2369
+ return this.baseHttpService.upload({
2370
+ method: 'post',
2371
+ url: `${this.serviceUrl}/${templateId}/thumbnail`,
2372
+ body: data,
2373
+ });
2374
+ }
2375
+ removeTemplateThumbnail$(templateId) {
2376
+ return this.baseHttpService.api({
2377
+ method: 'delete',
2378
+ url: `${this.serviceUrl}/${templateId}/thumbnail`,
2379
+ });
2380
+ }
2381
+ }
2382
+ UITemplatesApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: UITemplatesApiService, deps: [{ token: i1.BaseHttpService }], target: i0.ɵɵFactoryTarget.Injectable });
2383
+ UITemplatesApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: UITemplatesApiService });
2384
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: UITemplatesApiService, decorators: [{
2385
+ type: Injectable
2386
+ }], ctorParameters: function () { return [{ type: i1.BaseHttpService }]; } });
2387
+
2388
+ class ApiModule {
2389
+ }
2390
+ ApiModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ApiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2391
+ ApiModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: ApiModule, imports: [HttpClientModule] });
2392
+ ApiModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ApiModule, providers: [
2393
+ BaseHttpService,
2394
+ XrayService,
2395
+ ConfigurationApiService,
2396
+ ConfigurationSettingsApiService,
2397
+ ContextApiService,
2398
+ DocumentAttachmentApiService,
2399
+ PriceApiService,
2400
+ ProductModelApiService,
2401
+ ProceduresApiService,
2402
+ QuoteApiService,
2403
+ DocumentTemplatesApiService,
2404
+ RampApiService,
2405
+ SalesforceApiService,
2406
+ UITemplatesApiService,
2407
+ ScriptsApiService,
2408
+ RulesApiService,
2409
+ RuleGroupsApiService,
2410
+ FlowsApiService,
2411
+ GuidedSellingsAdminApiService,
2412
+ ShoppingCartSettingsApiService,
2413
+ ProductApiService,
2414
+ CatalogAdminApiService,
2415
+ GuidedSellingApiService,
2416
+ CatalogApiService,
2417
+ DeltaApiService,
2418
+ AccountApiService,
2419
+ PicklistsApiService,
2420
+ EndpointsApiService,
2421
+ OrgInfoApiService,
2422
+ OffersApiService,
2423
+ ], imports: [HttpClientModule] });
2424
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ApiModule, decorators: [{
2425
+ type: NgModule,
2426
+ args: [{
2427
+ imports: [HttpClientModule],
2428
+ providers: [
2429
+ BaseHttpService,
2430
+ XrayService,
2431
+ ConfigurationApiService,
2432
+ ConfigurationSettingsApiService,
2433
+ ContextApiService,
2434
+ DocumentAttachmentApiService,
2435
+ PriceApiService,
2436
+ ProductModelApiService,
2437
+ ProceduresApiService,
2438
+ QuoteApiService,
2439
+ DocumentTemplatesApiService,
2440
+ RampApiService,
2441
+ SalesforceApiService,
2442
+ UITemplatesApiService,
2443
+ ScriptsApiService,
2444
+ RulesApiService,
2445
+ RuleGroupsApiService,
2446
+ FlowsApiService,
2447
+ GuidedSellingsAdminApiService,
2448
+ ShoppingCartSettingsApiService,
2449
+ ProductApiService,
2450
+ CatalogAdminApiService,
2451
+ GuidedSellingApiService,
2452
+ CatalogApiService,
2453
+ DeltaApiService,
2454
+ AccountApiService,
2455
+ PicklistsApiService,
2456
+ EndpointsApiService,
2457
+ OrgInfoApiService,
2458
+ OffersApiService,
2459
+ ],
2460
+ }]
2461
+ }] });
2462
+
2463
+ /**
2464
+ * Generated bundle index. Do not edit.
2465
+ */
2466
+
2467
+ export { AccountApiService, ApiModule, CatalogAdminApiService, CatalogApiService, ConfigurationApiService, ConfigurationSettingsApiService, ContextApiService, DeltaApiService, DocumentAttachmentApiService, DocumentTemplatesApiService, EndpointsApiService, FlowsApiService, GuidedSellingApiService, GuidedSellingsAdminApiService, OffersApiService, OrgInfoApiService, PicklistsApiService, PriceApiService, ProceduresApiService, ProductApiService, ProductModelApiService, QuoteApiService, RampApiService, RuleGroupsApiService, RulesApiService, SalesforceApiService, ScriptsApiService, ShoppingCartSettingsApiService, UITemplatesApiService };
2468
+ //# sourceMappingURL=veloceapps-api.mjs.map