@configura/web-api 2.2.0-alpha.1 → 2.2.0-alpha.3

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 (102) hide show
  1. package/.eslintrc.json +5 -5
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/CatalogueAPI.d.ts +633 -633
  5. package/dist/CatalogueAPI.js +312 -312
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +359 -344
  9. package/dist/CfgProduct.js +1005 -992
  10. package/dist/CfgReferencePathHelper.d.ts +26 -26
  11. package/dist/CfgReferencePathHelper.js +26 -26
  12. package/dist/index.d.ts +24 -24
  13. package/dist/index.js +24 -24
  14. package/dist/io/CfgHistoryManager.d.ts +83 -83
  15. package/dist/io/CfgHistoryManager.js +144 -144
  16. package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -21
  17. package/dist/io/CfgHistoryToProdConfConnector.js +50 -50
  18. package/dist/io/CfgIOManager.d.ts +53 -53
  19. package/dist/io/CfgIOManager.js +134 -134
  20. package/dist/io/CfgIOProdConfConnector.d.ts +54 -54
  21. package/dist/io/CfgIOProdConfConnector.js +139 -139
  22. package/dist/io/CfgIOWarningSupplier.d.ts +3 -3
  23. package/dist/io/CfgIOWarningSupplier.js +1 -1
  24. package/dist/io/CfgObservableStateManager.d.ts +25 -25
  25. package/dist/io/CfgObservableStateManager.js +69 -69
  26. package/dist/io/CfgObservableStateToProdConfConnector.d.ts +15 -15
  27. package/dist/io/CfgObservableStateToProdConfConnector.js +17 -17
  28. package/dist/io/CfgWindowEventManager.d.ts +21 -21
  29. package/dist/io/CfgWindowEventManager.js +38 -38
  30. package/dist/io/CfgWindowMessageManager.d.ts +40 -40
  31. package/dist/io/CfgWindowMessageManager.js +91 -91
  32. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +17 -17
  33. package/dist/io/CfgWindowMessageToProdConfConnector.js +19 -19
  34. package/dist/io/index.d.ts +8 -8
  35. package/dist/io/index.js +8 -8
  36. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  37. package/dist/material/CfgMaterialMapping.js +181 -181
  38. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  39. package/dist/material/CfgMtrlApplication.js +43 -43
  40. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  41. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  42. package/dist/material/CfgMtrlSource.d.ts +19 -19
  43. package/dist/material/CfgMtrlSource.js +40 -40
  44. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  45. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  46. package/dist/productConfiguration/CfgFeature.d.ts +199 -199
  47. package/dist/productConfiguration/CfgFeature.js +691 -691
  48. package/dist/productConfiguration/CfgOption.d.ts +160 -160
  49. package/dist/productConfiguration/CfgOption.js +464 -464
  50. package/dist/productConfiguration/CfgProductConfiguration.d.ts +136 -129
  51. package/dist/productConfiguration/CfgProductConfiguration.js +355 -346
  52. package/dist/productConfiguration/filters.d.ts +17 -17
  53. package/dist/productConfiguration/filters.js +141 -141
  54. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  55. package/dist/productConfiguration/productParamsGenerator.js +65 -65
  56. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
  57. package/dist/productConfiguration/utilitiesProductConfiguration.js +89 -87
  58. package/dist/productLoader.d.ts +33 -33
  59. package/dist/productLoader.js +49 -49
  60. package/dist/syncGroups/SyncGroupsApplyMode.d.ts +20 -20
  61. package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
  62. package/dist/syncGroups/SyncGroupsHandler.d.ts +47 -47
  63. package/dist/syncGroups/SyncGroupsHandler.js +370 -370
  64. package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
  65. package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
  66. package/dist/syncGroups/SyncGroupsState.d.ts +39 -39
  67. package/dist/syncGroups/SyncGroupsState.js +167 -167
  68. package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
  69. package/dist/syncGroups/SyncGroupsTransaction.js +589 -589
  70. package/dist/tasks/TaskHandler.d.ts +77 -77
  71. package/dist/tasks/TaskHandler.js +276 -276
  72. package/dist/tasks/formats.d.ts +4 -4
  73. package/dist/tasks/formats.js +7 -7
  74. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  75. package/dist/tests/testData/collectorForTest.js +194 -194
  76. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  77. package/dist/tests/testData/dummyProductForTest.js +32 -32
  78. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
  79. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +282 -282
  80. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  81. package/dist/tests/testData/testDataCachedGetProduct.js +187 -187
  82. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  83. package/dist/tests/testData/testDataCachedPostValidate.js +185 -185
  84. package/dist/tests/testData/testDataConstraints.d.ts +3 -3
  85. package/dist/tests/testData/testDataConstraints.js +174 -174
  86. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  87. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
  88. package/dist/tests/testData/testDataOptions.d.ts +12 -12
  89. package/dist/tests/testData/testDataOptions.js +60 -60
  90. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
  91. package/dist/tests/testData/testDataProductAggregatedPrice.js +189 -189
  92. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  93. package/dist/tests/testData/testDataUpcharge.js +121 -121
  94. package/dist/utilitiesCatalogueData.d.ts +47 -47
  95. package/dist/utilitiesCatalogueData.js +180 -180
  96. package/dist/utilitiesCataloguePermission.d.ts +38 -38
  97. package/dist/utilitiesCataloguePermission.js +79 -79
  98. package/dist/utilitiesConfiguration.d.ts +28 -28
  99. package/dist/utilitiesConfiguration.js +200 -200
  100. package/dist/utilitiesNumericValues.d.ts +24 -24
  101. package/dist/utilitiesNumericValues.js +114 -114
  102. package/package.json +3 -3
@@ -1,312 +1,312 @@
1
- // WARNING: This file was auto generated by the code in web-rnd/tygen.
2
- // Do not commit manual changes to this file.
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
- // @ts-ignore
14
- import packageInfo from "../package.json";
15
- export const dtoExportFormatNames = ["glb", "gltf", "fbx", "dwg", "cmdrw", "cmfav", "cmsym"];
16
- export const dtoExportStatusStatusNames = ["pending", "running", "finished", "failed"];
17
- export const dtoNoteSeverityNames = ["Information", "Critical", "Warning"];
18
- export const dtoRenderFormatNames = ["jpg", "png"];
19
- export const dtoRenderStatusStatusNames = ["pending", "running", "finished", "failed"];
20
- export const dtoSyncGroupMethodsNames = ["pull", "push", "twoWay"];
21
- export class DtoAPIError extends Error {
22
- }
23
- export class CatalogueAPI {
24
- constructor(_fetch = window.fetch.bind(window)) {
25
- this._fetch = _fetch;
26
- }
27
- // For internal use
28
- _saveAlternativeReferer() {
29
- if (typeof document === "undefined") {
30
- return;
31
- }
32
- const parts = new RegExp("^(http[s]?:\\/\\/[^:\\/\\s]+)", "i").exec(document.referrer);
33
- if (parts !== null) {
34
- this._alternativeReferer = parts[1];
35
- }
36
- }
37
- hasFeature(feature) {
38
- return this.auth !== undefined && this.auth.apiSession.features !== undefined && this.auth.apiSession.features.indexOf(feature) > -1;
39
- }
40
- fetch(url, options) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- let response;
43
- let body;
44
- let err;
45
- if (options.method === "POST" && options.body) {
46
- options.headers["Content-Type"] = "application/json;charset=utf-8";
47
- }
48
- try {
49
- response = yield this._fetch(url, options);
50
- body = yield response.text();
51
- const parsed = JSON.parse(body);
52
- if (parsed && typeof parsed === "object" && "error" in parsed) {
53
- err = new DtoAPIError(parsed.error);
54
- err.body = body;
55
- err.status = response.status;
56
- err.parsed = parsed;
57
- }
58
- else {
59
- return parsed;
60
- }
61
- }
62
- catch (e) {
63
- const msg = e instanceof Error ? e.message : `${e}`;
64
- err = new DtoAPIError(msg);
65
- err.body = body;
66
- err.status = response && response.status;
67
- err.error = e instanceof Error ? e : Error(msg);
68
- }
69
- throw err;
70
- });
71
- }
72
- postPublicAccessTokenAuthorize(params, endpoint) {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- const url = `/v1/access-token/public/${encodeURIComponent(params.accessTokenId)}/authorize`;
75
- const options = {
76
- method: "POST",
77
- headers: { "X-SDK-Version": packageInfo.version },
78
- };
79
- if (this._alternativeReferer) {
80
- options.headers["Alternative-Referer"] = this._alternativeReferer;
81
- }
82
- return this.fetch(endpoint + url, options);
83
- });
84
- }
85
- getApplicationAreas(params) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- if (this.auth === undefined) {
88
- throw new Error("missing auth");
89
- }
90
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/application-areas`;
91
- const options = {
92
- method: "GET",
93
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
94
- };
95
- if (this._alternativeReferer) {
96
- options.headers["Alternative-Referer"] = this._alternativeReferer;
97
- }
98
- return this.fetch(this.auth.endpoint + url, options);
99
- });
100
- }
101
- postExport(params, body) {
102
- return __awaiter(this, void 0, void 0, function* () {
103
- if (this.auth === undefined) {
104
- throw new Error("missing auth");
105
- }
106
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/export/${encodeURIComponent(params.partNumber)}`;
107
- const options = {
108
- method: "POST",
109
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
110
- body: JSON.stringify(body),
111
- };
112
- if (this._alternativeReferer) {
113
- options.headers["Alternative-Referer"] = this._alternativeReferer;
114
- }
115
- return this.fetch(this.auth.endpoint + url, options);
116
- });
117
- }
118
- getPriceLists(params) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- if (this.auth === undefined) {
121
- throw new Error("missing auth");
122
- }
123
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/price-lists`;
124
- const options = {
125
- method: "GET",
126
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
127
- };
128
- if (this._alternativeReferer) {
129
- options.headers["Alternative-Referer"] = this._alternativeReferer;
130
- }
131
- return this.fetch(this.auth.endpoint + url, options);
132
- });
133
- }
134
- getProductLegacyV2(params) {
135
- return __awaiter(this, void 0, void 0, function* () {
136
- if (this.auth === undefined) {
137
- throw new Error("missing auth");
138
- }
139
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product-v2/${encodeURIComponent(params.partNumber)}`;
140
- const options = {
141
- method: "GET",
142
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
143
- };
144
- if (this._alternativeReferer) {
145
- options.headers["Alternative-Referer"] = this._alternativeReferer;
146
- }
147
- return this.fetch(this.auth.endpoint + url, options);
148
- });
149
- }
150
- getProduct(params) {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- if (this.auth === undefined) {
153
- throw new Error("missing auth");
154
- }
155
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product-v3/${encodeURIComponent(params.partNumber)}`;
156
- const options = {
157
- method: "GET",
158
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
159
- };
160
- if (this._alternativeReferer) {
161
- options.headers["Alternative-Referer"] = this._alternativeReferer;
162
- }
163
- return this.fetch(this.auth.endpoint + url, options);
164
- });
165
- }
166
- postRender(params, body) {
167
- return __awaiter(this, void 0, void 0, function* () {
168
- if (this.auth === undefined) {
169
- throw new Error("missing auth");
170
- }
171
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product/${encodeURIComponent(params.partNumber)}/render`;
172
- const options = {
173
- method: "POST",
174
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
175
- body: JSON.stringify(body),
176
- };
177
- if (this._alternativeReferer) {
178
- options.headers["Alternative-Referer"] = this._alternativeReferer;
179
- }
180
- return this.fetch(this.auth.endpoint + url, options);
181
- });
182
- }
183
- postValidateLegacyV1(params, body) {
184
- return __awaiter(this, void 0, void 0, function* () {
185
- if (this.auth === undefined) {
186
- throw new Error("missing auth");
187
- }
188
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product/${encodeURIComponent(params.partNumber)}/validate`;
189
- const options = {
190
- method: "POST",
191
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
192
- body: JSON.stringify(body),
193
- };
194
- if (this._alternativeReferer) {
195
- options.headers["Alternative-Referer"] = this._alternativeReferer;
196
- }
197
- return this.fetch(this.auth.endpoint + url, options);
198
- });
199
- }
200
- postValidate(params, body) {
201
- return __awaiter(this, void 0, void 0, function* () {
202
- if (this.auth === undefined) {
203
- throw new Error("missing auth");
204
- }
205
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product/${encodeURIComponent(params.partNumber)}/validate-v2`;
206
- const options = {
207
- method: "POST",
208
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
209
- body: JSON.stringify(body),
210
- };
211
- if (this._alternativeReferer) {
212
- options.headers["Alternative-Referer"] = this._alternativeReferer;
213
- }
214
- return this.fetch(this.auth.endpoint + url, options);
215
- });
216
- }
217
- getTocTree(params) {
218
- return __awaiter(this, void 0, void 0, function* () {
219
- if (this.auth === undefined) {
220
- throw new Error("missing auth");
221
- }
222
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/toc`;
223
- const options = {
224
- method: "GET",
225
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
226
- };
227
- if (this._alternativeReferer) {
228
- options.headers["Alternative-Referer"] = this._alternativeReferer;
229
- }
230
- return this.fetch(this.auth.endpoint + url, options);
231
- });
232
- }
233
- getTocFlat(params) {
234
- return __awaiter(this, void 0, void 0, function* () {
235
- if (this.auth === undefined) {
236
- throw new Error("missing auth");
237
- }
238
- const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/toc/flat`;
239
- const options = {
240
- method: "GET",
241
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
242
- };
243
- if (this._alternativeReferer) {
244
- options.headers["Alternative-Referer"] = this._alternativeReferer;
245
- }
246
- return this.fetch(this.auth.endpoint + url, options);
247
- });
248
- }
249
- getExportById(params) {
250
- return __awaiter(this, void 0, void 0, function* () {
251
- if (this.auth === undefined) {
252
- throw new Error("missing auth");
253
- }
254
- const url = `/v1/export/${encodeURIComponent(params.uuid)}`;
255
- const options = {
256
- method: "GET",
257
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
258
- };
259
- if (this._alternativeReferer) {
260
- options.headers["Alternative-Referer"] = this._alternativeReferer;
261
- }
262
- return this.fetch(this.auth.endpoint + url, options);
263
- });
264
- }
265
- getRenderById(params) {
266
- return __awaiter(this, void 0, void 0, function* () {
267
- if (this.auth === undefined) {
268
- throw new Error("missing auth");
269
- }
270
- const url = `/v1/render/${encodeURIComponent(params.uuid)}`;
271
- const options = {
272
- method: "GET",
273
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
274
- };
275
- if (this._alternativeReferer) {
276
- options.headers["Alternative-Referer"] = this._alternativeReferer;
277
- }
278
- return this.fetch(this.auth.endpoint + url, options);
279
- });
280
- }
281
- postSessionTokenRefresh() {
282
- return __awaiter(this, void 0, void 0, function* () {
283
- if (this.auth === undefined) {
284
- throw new Error("missing auth");
285
- }
286
- const url = `/v1/session-token/refresh`;
287
- const options = {
288
- method: "POST",
289
- headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
290
- };
291
- if (this._alternativeReferer) {
292
- options.headers["Alternative-Referer"] = this._alternativeReferer;
293
- }
294
- return this.fetch(this.auth.endpoint + url, options);
295
- });
296
- }
297
- }
298
- export const DTO_OPERATION_ID_TO_DEBIT_GROUP = {
299
- postPublicAccessTokenAuthorize: "base",
300
- getApplicationAreas: "base",
301
- postExport: "export",
302
- getPriceLists: "base",
303
- getProductLegacyV2: "base",
304
- getProduct: "base",
305
- postRender: "render",
306
- postValidateLegacyV1: "base",
307
- postValidate: "base",
308
- getTocTree: "base",
309
- getTocFlat: "base",
310
- getExportById: "base",
311
- getRenderById: "base",
312
- };
1
+ // WARNING: This file was auto generated by the code in web-rnd/tygen.
2
+ // Do not commit manual changes to this file.
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
+ // @ts-ignore
14
+ import packageInfo from "../package.json";
15
+ export const dtoExportFormatNames = ["glb", "gltf", "fbx", "dwg", "cmdrw", "cmfav", "cmsym"];
16
+ export const dtoExportStatusStatusNames = ["pending", "running", "finished", "failed"];
17
+ export const dtoNoteSeverityNames = ["Information", "Critical", "Warning"];
18
+ export const dtoRenderFormatNames = ["jpg", "png"];
19
+ export const dtoRenderStatusStatusNames = ["pending", "running", "finished", "failed"];
20
+ export const dtoSyncGroupMethodsNames = ["pull", "push", "twoWay"];
21
+ export class DtoAPIError extends Error {
22
+ }
23
+ export class CatalogueAPI {
24
+ constructor(_fetch = window.fetch.bind(window)) {
25
+ this._fetch = _fetch;
26
+ }
27
+ // For internal use
28
+ _saveAlternativeReferer() {
29
+ if (typeof document === "undefined") {
30
+ return;
31
+ }
32
+ const parts = new RegExp("^(http[s]?:\\/\\/[^:\\/\\s]+)", "i").exec(document.referrer);
33
+ if (parts !== null) {
34
+ this._alternativeReferer = parts[1];
35
+ }
36
+ }
37
+ hasFeature(feature) {
38
+ return this.auth !== undefined && this.auth.apiSession.features !== undefined && this.auth.apiSession.features.indexOf(feature) > -1;
39
+ }
40
+ fetch(url, options) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ let response;
43
+ let body;
44
+ let err;
45
+ if (options.method === "POST" && options.body) {
46
+ options.headers["Content-Type"] = "application/json;charset=utf-8";
47
+ }
48
+ try {
49
+ response = yield this._fetch(url, options);
50
+ body = yield response.text();
51
+ const parsed = JSON.parse(body);
52
+ if (parsed && typeof parsed === "object" && "error" in parsed) {
53
+ err = new DtoAPIError(parsed.error);
54
+ err.body = body;
55
+ err.status = response.status;
56
+ err.parsed = parsed;
57
+ }
58
+ else {
59
+ return parsed;
60
+ }
61
+ }
62
+ catch (e) {
63
+ const msg = e instanceof Error ? e.message : `${e}`;
64
+ err = new DtoAPIError(msg);
65
+ err.body = body;
66
+ err.status = response && response.status;
67
+ err.error = e instanceof Error ? e : Error(msg);
68
+ }
69
+ throw err;
70
+ });
71
+ }
72
+ postPublicAccessTokenAuthorize(params, endpoint) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ const url = `/v1/access-token/public/${encodeURIComponent(params.accessTokenId)}/authorize`;
75
+ const options = {
76
+ method: "POST",
77
+ headers: { "X-SDK-Version": packageInfo.version },
78
+ };
79
+ if (this._alternativeReferer) {
80
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
81
+ }
82
+ return this.fetch(endpoint + url, options);
83
+ });
84
+ }
85
+ getApplicationAreas(params) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ if (this.auth === undefined) {
88
+ throw new Error("missing auth");
89
+ }
90
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/application-areas`;
91
+ const options = {
92
+ method: "GET",
93
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
94
+ };
95
+ if (this._alternativeReferer) {
96
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
97
+ }
98
+ return this.fetch(this.auth.endpoint + url, options);
99
+ });
100
+ }
101
+ postExport(params, body) {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ if (this.auth === undefined) {
104
+ throw new Error("missing auth");
105
+ }
106
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/export/${encodeURIComponent(params.partNumber)}`;
107
+ const options = {
108
+ method: "POST",
109
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
110
+ body: JSON.stringify(body),
111
+ };
112
+ if (this._alternativeReferer) {
113
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
114
+ }
115
+ return this.fetch(this.auth.endpoint + url, options);
116
+ });
117
+ }
118
+ getPriceLists(params) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ if (this.auth === undefined) {
121
+ throw new Error("missing auth");
122
+ }
123
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/price-lists`;
124
+ const options = {
125
+ method: "GET",
126
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
127
+ };
128
+ if (this._alternativeReferer) {
129
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
130
+ }
131
+ return this.fetch(this.auth.endpoint + url, options);
132
+ });
133
+ }
134
+ getProductLegacyV2(params) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ if (this.auth === undefined) {
137
+ throw new Error("missing auth");
138
+ }
139
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product-v2/${encodeURIComponent(params.partNumber)}`;
140
+ const options = {
141
+ method: "GET",
142
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
143
+ };
144
+ if (this._alternativeReferer) {
145
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
146
+ }
147
+ return this.fetch(this.auth.endpoint + url, options);
148
+ });
149
+ }
150
+ getProduct(params) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ if (this.auth === undefined) {
153
+ throw new Error("missing auth");
154
+ }
155
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product-v3/${encodeURIComponent(params.partNumber)}`;
156
+ const options = {
157
+ method: "GET",
158
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
159
+ };
160
+ if (this._alternativeReferer) {
161
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
162
+ }
163
+ return this.fetch(this.auth.endpoint + url, options);
164
+ });
165
+ }
166
+ postRender(params, body) {
167
+ return __awaiter(this, void 0, void 0, function* () {
168
+ if (this.auth === undefined) {
169
+ throw new Error("missing auth");
170
+ }
171
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product/${encodeURIComponent(params.partNumber)}/render`;
172
+ const options = {
173
+ method: "POST",
174
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
175
+ body: JSON.stringify(body),
176
+ };
177
+ if (this._alternativeReferer) {
178
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
179
+ }
180
+ return this.fetch(this.auth.endpoint + url, options);
181
+ });
182
+ }
183
+ postValidateLegacyV1(params, body) {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ if (this.auth === undefined) {
186
+ throw new Error("missing auth");
187
+ }
188
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product/${encodeURIComponent(params.partNumber)}/validate`;
189
+ const options = {
190
+ method: "POST",
191
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
192
+ body: JSON.stringify(body),
193
+ };
194
+ if (this._alternativeReferer) {
195
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
196
+ }
197
+ return this.fetch(this.auth.endpoint + url, options);
198
+ });
199
+ }
200
+ postValidate(params, body) {
201
+ return __awaiter(this, void 0, void 0, function* () {
202
+ if (this.auth === undefined) {
203
+ throw new Error("missing auth");
204
+ }
205
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/product/${encodeURIComponent(params.partNumber)}/validate-v2`;
206
+ const options = {
207
+ method: "POST",
208
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
209
+ body: JSON.stringify(body),
210
+ };
211
+ if (this._alternativeReferer) {
212
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
213
+ }
214
+ return this.fetch(this.auth.endpoint + url, options);
215
+ });
216
+ }
217
+ getTocTree(params) {
218
+ return __awaiter(this, void 0, void 0, function* () {
219
+ if (this.auth === undefined) {
220
+ throw new Error("missing auth");
221
+ }
222
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/toc`;
223
+ const options = {
224
+ method: "GET",
225
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
226
+ };
227
+ if (this._alternativeReferer) {
228
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
229
+ }
230
+ return this.fetch(this.auth.endpoint + url, options);
231
+ });
232
+ }
233
+ getTocFlat(params) {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ if (this.auth === undefined) {
236
+ throw new Error("missing auth");
237
+ }
238
+ const url = `/v1/catalogue/${encodeURIComponent(params.lang)}/${encodeURIComponent(params.enterprise)}/${encodeURIComponent(params.prdCat)}/${encodeURIComponent(params.prdCatVersion)}/${encodeURIComponent(params.vendor)}/${encodeURIComponent(params.priceList)}/toc/flat`;
239
+ const options = {
240
+ method: "GET",
241
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
242
+ };
243
+ if (this._alternativeReferer) {
244
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
245
+ }
246
+ return this.fetch(this.auth.endpoint + url, options);
247
+ });
248
+ }
249
+ getExportById(params) {
250
+ return __awaiter(this, void 0, void 0, function* () {
251
+ if (this.auth === undefined) {
252
+ throw new Error("missing auth");
253
+ }
254
+ const url = `/v1/export/${encodeURIComponent(params.uuid)}`;
255
+ const options = {
256
+ method: "GET",
257
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
258
+ };
259
+ if (this._alternativeReferer) {
260
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
261
+ }
262
+ return this.fetch(this.auth.endpoint + url, options);
263
+ });
264
+ }
265
+ getRenderById(params) {
266
+ return __awaiter(this, void 0, void 0, function* () {
267
+ if (this.auth === undefined) {
268
+ throw new Error("missing auth");
269
+ }
270
+ const url = `/v1/render/${encodeURIComponent(params.uuid)}`;
271
+ const options = {
272
+ method: "GET",
273
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
274
+ };
275
+ if (this._alternativeReferer) {
276
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
277
+ }
278
+ return this.fetch(this.auth.endpoint + url, options);
279
+ });
280
+ }
281
+ postSessionTokenRefresh() {
282
+ return __awaiter(this, void 0, void 0, function* () {
283
+ if (this.auth === undefined) {
284
+ throw new Error("missing auth");
285
+ }
286
+ const url = `/v1/session-token/refresh`;
287
+ const options = {
288
+ method: "POST",
289
+ headers: { "X-API-Key": this.auth.secretToken || "", "X-SDK-Version": packageInfo.version },
290
+ };
291
+ if (this._alternativeReferer) {
292
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
293
+ }
294
+ return this.fetch(this.auth.endpoint + url, options);
295
+ });
296
+ }
297
+ }
298
+ export const DTO_OPERATION_ID_TO_DEBIT_GROUP = {
299
+ postPublicAccessTokenAuthorize: "base",
300
+ getApplicationAreas: "base",
301
+ postExport: "export",
302
+ getPriceLists: "base",
303
+ getProductLegacyV2: "base",
304
+ getProduct: "base",
305
+ postRender: "render",
306
+ postValidateLegacyV1: "base",
307
+ postValidate: "base",
308
+ getTocTree: "base",
309
+ getTocFlat: "base",
310
+ getExportById: "base",
311
+ getRenderById: "base",
312
+ };