@configura/web-api 1.3.0-alpha.7 → 1.4.0-alpha.2

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.
@@ -485,6 +485,8 @@ export declare class APIError<T> extends Error {
485
485
  }
486
486
  export declare class CatalogueAPI {
487
487
  auth: AuthorizeResponse | undefined;
488
+ constructor();
489
+ private _alternativeReferer;
488
490
  hasFeature(feature: string): boolean;
489
491
  fetch<T>(url: string, options: RequestOptions): Promise<T>;
490
492
  postPublicAccessTokenAuthorize(params: PostPublicAccessTokenAuthorizeParams, endpoint: string): Promise<AuthorizeResponse>;
@@ -12,8 +12,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  export class APIError extends Error {
13
13
  }
14
14
  export class CatalogueAPI {
15
+ constructor() {
16
+ const parts = /^(http[s]?:\/\/[^:\/\s]+)/i.exec(document.referrer);
17
+ if (parts !== null) {
18
+ this._alternativeReferer = parts[1] + "/";
19
+ }
20
+ }
15
21
  hasFeature(feature) {
16
- return this.auth !== undefined && this.auth.apiSession.features !== undefined && this.auth.apiSession.features.indexOf(feature) > -1;
22
+ return (this.auth !== undefined &&
23
+ this.auth.apiSession.features !== undefined &&
24
+ this.auth.apiSession.features.indexOf(feature) > -1);
17
25
  }
18
26
  fetch(url, options) {
19
27
  return __awaiter(this, void 0, void 0, function* () {
@@ -42,7 +50,7 @@ export class CatalogueAPI {
42
50
  err = new APIError(msg);
43
51
  err.body = body;
44
52
  err.status = response && response.status;
45
- err.error = e instanceof Error ? e : Error(e);
53
+ err.error = e instanceof Error ? e : Error(msg);
46
54
  }
47
55
  throw err;
48
56
  });
@@ -54,6 +62,9 @@ export class CatalogueAPI {
54
62
  method: "POST",
55
63
  headers: {},
56
64
  };
65
+ if (this._alternativeReferer) {
66
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
67
+ }
57
68
  return this.fetch(endpoint + url, options);
58
69
  });
59
70
  }
@@ -67,6 +78,9 @@ export class CatalogueAPI {
67
78
  method: "GET",
68
79
  headers: { "X-API-Key": this.auth.secretToken || "" },
69
80
  };
81
+ if (this._alternativeReferer) {
82
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
83
+ }
70
84
  return this.fetch(this.auth.endpoint + url, options);
71
85
  });
72
86
  }
@@ -81,6 +95,9 @@ export class CatalogueAPI {
81
95
  headers: { "X-API-Key": this.auth.secretToken || "" },
82
96
  body: JSON.stringify(body),
83
97
  };
98
+ if (this._alternativeReferer) {
99
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
100
+ }
84
101
  return this.fetch(this.auth.endpoint + url, options);
85
102
  });
86
103
  }
@@ -94,6 +111,9 @@ export class CatalogueAPI {
94
111
  method: "GET",
95
112
  headers: { "X-API-Key": this.auth.secretToken || "" },
96
113
  };
114
+ if (this._alternativeReferer) {
115
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
116
+ }
97
117
  return this.fetch(this.auth.endpoint + url, options);
98
118
  });
99
119
  }
@@ -107,6 +127,9 @@ export class CatalogueAPI {
107
127
  method: "GET",
108
128
  headers: { "X-API-Key": this.auth.secretToken || "" },
109
129
  };
130
+ if (this._alternativeReferer) {
131
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
132
+ }
110
133
  return this.fetch(this.auth.endpoint + url, options);
111
134
  });
112
135
  }
@@ -121,6 +144,9 @@ export class CatalogueAPI {
121
144
  headers: { "X-API-Key": this.auth.secretToken || "" },
122
145
  body: JSON.stringify(body),
123
146
  };
147
+ if (this._alternativeReferer) {
148
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
149
+ }
124
150
  return this.fetch(this.auth.endpoint + url, options);
125
151
  });
126
152
  }
@@ -135,6 +161,9 @@ export class CatalogueAPI {
135
161
  headers: { "X-API-Key": this.auth.secretToken || "" },
136
162
  body: JSON.stringify(body),
137
163
  };
164
+ if (this._alternativeReferer) {
165
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
166
+ }
138
167
  return this.fetch(this.auth.endpoint + url, options);
139
168
  });
140
169
  }
@@ -148,6 +177,9 @@ export class CatalogueAPI {
148
177
  method: "GET",
149
178
  headers: { "X-API-Key": this.auth.secretToken || "" },
150
179
  };
180
+ if (this._alternativeReferer) {
181
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
182
+ }
151
183
  return this.fetch(this.auth.endpoint + url, options);
152
184
  });
153
185
  }
@@ -161,6 +193,9 @@ export class CatalogueAPI {
161
193
  method: "GET",
162
194
  headers: { "X-API-Key": this.auth.secretToken || "" },
163
195
  };
196
+ if (this._alternativeReferer) {
197
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
198
+ }
164
199
  return this.fetch(this.auth.endpoint + url, options);
165
200
  });
166
201
  }
@@ -174,6 +209,9 @@ export class CatalogueAPI {
174
209
  method: "GET",
175
210
  headers: { "X-API-Key": this.auth.secretToken || "" },
176
211
  };
212
+ if (this._alternativeReferer) {
213
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
214
+ }
177
215
  return this.fetch(this.auth.endpoint + url, options);
178
216
  });
179
217
  }
@@ -187,6 +225,9 @@ export class CatalogueAPI {
187
225
  method: "GET",
188
226
  headers: { "X-API-Key": this.auth.secretToken || "" },
189
227
  };
228
+ if (this._alternativeReferer) {
229
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
230
+ }
190
231
  return this.fetch(this.auth.endpoint + url, options);
191
232
  });
192
233
  }
@@ -200,6 +241,9 @@ export class CatalogueAPI {
200
241
  method: "POST",
201
242
  headers: { "X-API-Key": this.auth.secretToken || "" },
202
243
  };
244
+ if (this._alternativeReferer) {
245
+ options.headers["Alternative-Referer"] = this._alternativeReferer;
246
+ }
203
247
  return this.fetch(this.auth.endpoint + url, options);
204
248
  });
205
249
  }
@@ -116,7 +116,7 @@ export declare class _CfgProductInternal {
116
116
  * product in isolation. The validation result is applied on the configuration. Then additional
117
117
  * products are synced (unloaded, loaded etc.) Finally the changes bubble up the tree.
118
118
  */
119
- _revalidate: (bubbleMode: CfgProductBubbleMode, productLoaderForGroupedLoad: ProductLoader) => Promise<boolean>;
119
+ _revalidate: (bubbleMode: CfgProductBubbleMode, productLoader: ProductLoader) => Promise<boolean>;
120
120
  /**
121
121
  * Based on this configuration find what additional products should be shown and not, unload
122
122
  * (i.e. destroy) those that should no longer be shown, load the new ones.
@@ -14,11 +14,11 @@ import { CfgProductConfiguration } from "./productConfiguration/CfgProductConfig
14
14
  import { collectAdditionalProductRefs } from "./productConfiguration/utilitiesProductConfiguration.js";
15
15
  import { wrapWithCache } from "./productLoader.js";
16
16
  import { comparePricesObjects, correctDefaultsOnCatalogueParams, makeProductKey, } from "./utilitiesCatalogueData.js";
17
- function completeSettings(uncompleteSettings) {
17
+ function completeSettings(incompleteSettings) {
18
18
  var _a, _b;
19
19
  return {
20
- strictSelectOneSelectionCount: (_a = uncompleteSettings === null || uncompleteSettings === void 0 ? void 0 : uncompleteSettings.strictSelectOneSelectionCount) !== null && _a !== void 0 ? _a : false,
21
- strictSetApiSelectionMatch: (_b = uncompleteSettings === null || uncompleteSettings === void 0 ? void 0 : uncompleteSettings.strictSetApiSelectionMatch) !== null && _b !== void 0 ? _b : false,
20
+ strictSelectOneSelectionCount: (_a = incompleteSettings === null || incompleteSettings === void 0 ? void 0 : incompleteSettings.strictSelectOneSelectionCount) !== null && _a !== void 0 ? _a : false,
21
+ strictSetApiSelectionMatch: (_b = incompleteSettings === null || incompleteSettings === void 0 ? void 0 : incompleteSettings.strictSetApiSelectionMatch) !== null && _b !== void 0 ? _b : false,
22
22
  };
23
23
  }
24
24
  /**
@@ -145,8 +145,9 @@ export class _CfgProductInternal {
145
145
  additionalProducts: this.additionalProducts.map((additionalProduct) => additionalProduct.getApiSelection()),
146
146
  });
147
147
  this.setApiSelection = (s, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
148
- // wrap with cache will make getProduct for this function call use the same server call
149
- // for the same product with the same params
148
+ // Wrap with cache will make getProduct for this function call use the same server call
149
+ // for the same product with the same params. Used for getProduct (when a new additional
150
+ // product is loaded) and postValidate.
150
151
  productLoaderForGroupedLoad =
151
152
  productLoaderForGroupedLoad || wrapWithCache(this._productLoaderRaw);
152
153
  const configurationChange = yield this.configuration._internal.setApiSelection(s.selOptions, false);
@@ -263,12 +264,12 @@ export class _CfgProductInternal {
263
264
  * product in isolation. The validation result is applied on the configuration. Then additional
264
265
  * products are synced (unloaded, loaded etc.) Finally the changes bubble up the tree.
265
266
  */
266
- this._revalidate = (bubbleMode, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
267
+ this._revalidate = (bubbleMode, productLoader) => __awaiter(this, void 0, void 0, function* () {
267
268
  const { _configuration: configuration } = this;
268
269
  const token = this.loadingObservable.startChildLoading();
269
270
  this._revalidateInProgressToken = token;
270
271
  try {
271
- const response = yield productLoaderForGroupedLoad.postValidate(Object.assign(Object.assign({ lang: this.lang }, correctDefaultsOnCatalogueParams(this.catId)), { partNumber: this.partNumber }), { selOptions: configuration.getApiSelection() });
272
+ const response = yield productLoader.postValidate(Object.assign(Object.assign({ lang: this.lang }, correctDefaultsOnCatalogueParams(this.catId)), { partNumber: this.partNumber }), { selOptions: configuration.getApiSelection() });
272
273
  // The revalidateInProgressToken is used to know if some other revalidate
273
274
  // call has happened after this call, thereby making this call obsolete.
274
275
  // This is a bit crude in that it does not actually cancel previous validate
@@ -298,7 +299,7 @@ export class _CfgProductInternal {
298
299
  this._configuration = CfgProductConfiguration._makeNewRefFrom(this._configuration._internal);
299
300
  }
300
301
  yield configuration._internal.setApiSelection(productData.partsData.selOptions || [], false);
301
- yield this._syncAndLoadAdditionalProducts(productLoaderForGroupedLoad);
302
+ yield this._syncAndLoadAdditionalProducts(productLoader);
302
303
  if (this._destroyed) {
303
304
  return false;
304
305
  }
@@ -473,8 +474,9 @@ export class _CfgProductInternal {
473
474
  }
474
475
  _CfgProductInternal.make = (productLoaderRaw, productLoaderForGroupedLoad, // Used when instantiating the current product
475
476
  lang, catId, partNumber, settings, optional, loadingObservable, refKey, refDescription, parent, root, transform, anchor) => __awaiter(void 0, void 0, void 0, function* () {
476
- // wrap with cache will make getProduct for this function call use the same server call
477
- // for the same product with the same params
477
+ // Wrap with cache will make getProduct for this function call use the same server call
478
+ // for the same product with the same params. Not retained for future calls, only used
479
+ // at this initial load.
478
480
  productLoaderForGroupedLoad =
479
481
  productLoaderForGroupedLoad || wrapWithCache(productLoaderRaw);
480
482
  const productResponse = yield productLoaderForGroupedLoad.getProduct(Object.assign(Object.assign({ lang }, correctDefaultsOnCatalogueParams(catId)), { partNumber }));
@@ -11,7 +11,7 @@ export declare type OptionChangeNotification = {
11
11
  export declare enum ProductConfigurationBubbleMode {
12
12
  /**
13
13
  * Bubble to the closest CfgProduct, let it revalidate, then that will continue
14
- * the bubble after validate. Turns on all ancestors all the way up.
14
+ * the bubble after validate.
15
15
  */
16
16
  Validate = "Validate",
17
17
  /**
@@ -19,7 +19,7 @@ export var ProductConfigurationBubbleMode;
19
19
  (function (ProductConfigurationBubbleMode) {
20
20
  /**
21
21
  * Bubble to the closest CfgProduct, let it revalidate, then that will continue
22
- * the bubble after validate. Turns on all ancestors all the way up.
22
+ * the bubble after validate.
23
23
  */
24
24
  ProductConfigurationBubbleMode["Validate"] = "Validate";
25
25
  /**
@@ -1,8 +1,16 @@
1
1
  import { Filters, Matches } from "@configura/web-utilities";
2
- import { CatalogueParams, ProductRef } from "../CatalogueAPI.js";
2
+ import { CatalogueParams, Level, ProductRef } from "../CatalogueAPI.js";
3
3
  export declare function applyCatalogueFilters(filters: Filters<CatalogueParams>, catalogues: CatalogueParams[]): [Matches<CatalogueParams>, CatalogueParams[]];
4
4
  export interface ProductRefParams {
5
5
  partNr: string;
6
6
  }
7
7
  export declare function applyProductRefFilters(filters: Filters<ProductRefParams>, productRefs: ProductRef[]): [Matches<ProductRefParams>, ProductRef[]];
8
+ /**
9
+ * Clones the table of content levels tree.
10
+ * Filters to only include passed products.
11
+ * @param levels The original data
12
+ * @param prdRefsFilter Products not in this array are removed
13
+ * @param showEmpty Shall empty levels be shown?
14
+ */
15
+ export declare function cloneFilterSortLevels(levels: Level[], prdRefsFilter: ProductRef[], showEmpty: boolean): Level[] | undefined;
8
16
  //# sourceMappingURL=filters.d.ts.map
@@ -27,3 +27,41 @@ export function applyProductRefFilters(filters, productRefs) {
27
27
  };
28
28
  return [args, result];
29
29
  }
30
+ /**
31
+ * Clones the table of content levels tree.
32
+ * Filters to only include passed products.
33
+ * @param levels The original data
34
+ * @param prdRefsFilter Products not in this array are removed
35
+ * @param showEmpty Shall empty levels be shown?
36
+ */
37
+ export function cloneFilterSortLevels(levels, prdRefsFilter, showEmpty) {
38
+ const newLevels = [];
39
+ for (const level of levels) {
40
+ // recursively fetch the next levels
41
+ let nextLevels;
42
+ if (level.lvls !== undefined) {
43
+ nextLevels = cloneFilterSortLevels(level.lvls, prdRefsFilter, showEmpty);
44
+ }
45
+ // filter out products
46
+ let newPrdRefs;
47
+ if (level.prdRefs !== undefined) {
48
+ newPrdRefs = level.prdRefs.filter((prod) => prdRefsFilter.some((p) => p.partNr === prod.prdRef));
49
+ }
50
+ // add copy of level if not empty
51
+ let addPrdRefs = showEmpty || (newPrdRefs !== undefined && newPrdRefs.length > 0);
52
+ if (nextLevels !== undefined || addPrdRefs) {
53
+ let newLevel = {
54
+ code: level.code,
55
+ description: level.description,
56
+ };
57
+ if (nextLevels !== undefined) {
58
+ newLevel.lvls = nextLevels;
59
+ }
60
+ if (addPrdRefs && newPrdRefs !== undefined) {
61
+ newLevel.prdRefs = newPrdRefs;
62
+ }
63
+ newLevels.push(newLevel);
64
+ }
65
+ }
66
+ return newLevels.sort((l1, l2) => l1.description.toLocaleLowerCase().localeCompare(l2.description.toLocaleLowerCase()));
67
+ }
@@ -122,37 +122,25 @@ const A = () => ({
122
122
  selOptions: [
123
123
  {
124
124
  code: "!~!",
125
- feature: "featureA",
126
- featDesc: "",
127
125
  next: {
128
126
  optionA: {
129
127
  code: "optionA",
130
- feature: "featureA",
131
- featDesc: "",
132
128
  },
133
129
  },
134
130
  },
135
131
  {
136
132
  code: "!~!",
137
- feature: "featureX",
138
- featDesc: "",
139
133
  next: {
140
134
  optionB: {
141
135
  code: "optionB",
142
- feature: "featureX",
143
- featDesc: "",
144
136
  },
145
137
  },
146
138
  },
147
139
  {
148
140
  code: "!~!",
149
- feature: "featureOptionCSelectedAtStart",
150
- featDesc: "",
151
141
  next: {
152
142
  optionC: {
153
143
  code: "optionC",
154
- feature: "featureOptionCSelectedAtStart",
155
- featDesc: "",
156
144
  },
157
145
  },
158
146
  },
@@ -210,13 +198,9 @@ const B = () => ({
210
198
  selOptions: [
211
199
  {
212
200
  code: "!~!",
213
- feature: "featureI",
214
- featDesc: "",
215
201
  next: {
216
202
  optionI0: {
217
203
  code: "optionI0",
218
- feature: "featureI",
219
- featDesc: "",
220
204
  },
221
205
  },
222
206
  },
@@ -261,13 +245,9 @@ const C = () => ({
261
245
  selOptions: [
262
246
  {
263
247
  code: "!~!",
264
- feature: "featureC",
265
- featDesc: "",
266
248
  next: {
267
249
  optionA: {
268
250
  code: "optionA",
269
- feature: "featureC",
270
- featDesc: "",
271
251
  },
272
252
  },
273
253
  },
@@ -313,17 +293,12 @@ export const cfgProductTest = (testFunc, prepFunc) => __awaiter(void 0, void 0,
313
293
  getProduct: getTestProduct,
314
294
  postValidate: (params, _body) => __awaiter(void 0, void 0, void 0, function* () {
315
295
  const productData = (yield getTestProduct(params)).productData;
316
- const feat = productData.partsData.selOptions[0].feature;
317
296
  productData.partsData.selOptions = [
318
297
  {
319
298
  code: "!~!",
320
- feature: feat,
321
- featDesc: "",
322
299
  next: {
323
300
  optionC: {
324
301
  code: "optionC",
325
- feature: feat,
326
- featDesc: "",
327
302
  },
328
303
  },
329
304
  },
@@ -331,25 +306,17 @@ export const cfgProductTest = (testFunc, prepFunc) => __awaiter(void 0, void 0,
331
306
  if (params.partNumber === "A") {
332
307
  productData.partsData.selOptions.push({
333
308
  code: "!~!",
334
- feature: "featureX",
335
- featDesc: "",
336
309
  next: {
337
310
  optionC: {
338
311
  code: "optionC",
339
- feature: "featureX",
340
- featDesc: "",
341
312
  },
342
313
  },
343
314
  });
344
315
  productData.partsData.selOptions.push({
345
316
  code: "!~!",
346
- feature: "featureOptionCSelectedAtStart",
347
- featDesc: "",
348
317
  next: {
349
318
  optionC: {
350
319
  code: "optionC",
351
- feature: "featureOptionCSelectedAtStart",
352
- featDesc: "",
353
320
  },
354
321
  },
355
322
  });
@@ -52,13 +52,9 @@ const A = () => ({
52
52
  selOptions: [
53
53
  {
54
54
  code: "!~!",
55
- feature: "featureA",
56
- featDesc: "",
57
55
  next: {
58
56
  optionA: {
59
57
  code: "optionA",
60
- feature: "featureA",
61
- featDesc: "",
62
58
  },
63
59
  },
64
60
  },
@@ -169,7 +165,6 @@ export const cachedProductLoaderTest = () => __awaiter(void 0, void 0, void 0, f
169
165
  getProduct: getTestProduct,
170
166
  postValidate: (params, _body) => __awaiter(void 0, void 0, void 0, function* () {
171
167
  const productData = (yield getTestProduct(params, true)).productData;
172
- const feat = productData.partsData.selOptions[0].feature;
173
168
  let code = "optionA";
174
169
  for (let test in _body.selOptions[0].next) {
175
170
  code = test;
@@ -178,13 +173,9 @@ export const cachedProductLoaderTest = () => __awaiter(void 0, void 0, void 0, f
178
173
  productData.partsData.selOptions = [
179
174
  {
180
175
  code: _body.selOptions[0].code,
181
- feature: feat,
182
- featDesc: "",
183
176
  next: {
184
177
  [code]: {
185
178
  code: code,
186
- feature: feat,
187
- featDesc: "",
188
179
  },
189
180
  },
190
181
  },
@@ -52,13 +52,9 @@ const Table = () => ({
52
52
  selOptions: [
53
53
  {
54
54
  code: "!~!",
55
- feature: "LegA",
56
- featDesc: "",
57
55
  next: {
58
56
  LegA: {
59
57
  code: "LegA",
60
- feature: "LegA",
61
- featDesc: "",
62
58
  },
63
59
  },
64
60
  },
@@ -102,13 +98,9 @@ const LegA = () => ({
102
98
  selOptions: [
103
99
  {
104
100
  code: "!~!",
105
- feature: "Color",
106
- featDesc: "",
107
101
  next: {
108
102
  Red: {
109
103
  code: "Red",
110
- feature: "Color",
111
- featDesc: "",
112
104
  },
113
105
  },
114
106
  },
@@ -148,13 +140,9 @@ const LegWheel = () => ({
148
140
  selOptions: [
149
141
  {
150
142
  code: "!~!",
151
- feature: "Color",
152
- featDesc: "",
153
143
  next: {
154
144
  Red: {
155
145
  code: "Red",
156
- feature: "Color",
157
- featDesc: "",
158
146
  },
159
147
  },
160
148
  },
@@ -1068,43 +1068,23 @@ export default {
1068
1068
  selOptions: [
1069
1069
  {
1070
1070
  code: "!~!",
1071
- feature: "SIDECHAIR-SHELL-OP",
1072
- featDesc: "Shell Color Options",
1073
1071
  next: {
1074
1072
  "WHITE PLASTIC": {
1075
1073
  code: "WHITE PLASTIC",
1076
- description: "White Plastic",
1077
- feature: "SIDECHAIR-SHELL-OP",
1078
- featDesc: "Shell Color Options",
1079
- upcharge: -0.0001,
1080
1074
  },
1081
1075
  },
1082
1076
  },
1083
1077
  {
1084
1078
  code: "!~!",
1085
- feature: "SIDECHAIR-ARMLESS-OP",
1086
- featDesc: "Chair Options",
1087
1079
  next: {
1088
1080
  "WOOD-LEG": {
1089
1081
  code: "WOOD-LEG",
1090
- description: "Wood Leg",
1091
- feature: "SIDECHAIR-ARMLESS-OP",
1092
- featDesc: "Chair Options",
1093
- upcharge: -0.0001,
1094
1082
  next: {
1095
1083
  PINE: {
1096
1084
  code: "PINE",
1097
- description: "Pine",
1098
- feature: "SIDECHAIR-WOOD-OP1",
1099
- featDesc: "Wood Leg Options",
1100
- upcharge: -0.0001,
1101
1085
  },
1102
1086
  WITHOUTCSHN: {
1103
1087
  code: "WITHOUTCSHN",
1104
- description: "Without Cushion",
1105
- feature: "SIDECHAIR-ARMLESS-CSHN",
1106
- featDesc: "Cushion Options",
1107
- upcharge: -0.0001,
1108
1088
  },
1109
1089
  },
1110
1090
  },
@@ -1,29 +1,7 @@
1
- import { GetProductParams } from "../../CatalogueAPI";
1
+ import { GetProductParams, SelectedOption } from "../../CatalogueAPI";
2
2
  import { CfgProduct } from "../../CfgProduct";
3
3
  import { CfgProductResponse } from "../../utilitiesCatalogueData";
4
4
  export declare const getTestProduct: (params: GetProductParams) => Promise<CfgProductResponse>;
5
- export declare function getSelOptions(option: string, feat: string): {
6
- code: string;
7
- feature: string;
8
- featDesc: string;
9
- next: {
10
- optionB: {
11
- code: string;
12
- feature: string;
13
- featDesc: string;
14
- };
15
- };
16
- }[] | {
17
- code: string;
18
- feature: string;
19
- featDesc: string;
20
- next: {
21
- optionC: {
22
- code: string;
23
- feature: string;
24
- featDesc: string;
25
- };
26
- };
27
- }[];
5
+ export declare function getSelOptions(option: string): SelectedOption[];
28
6
  export declare const cfgProductPriceTest: (testFunc?: ((cfgProduct: CfgProduct) => Promise<void>) | undefined, featureOption?: string | undefined) => Promise<CfgProduct>;
29
7
  //# sourceMappingURL=testDataProductAggregatedPrice.d.ts.map
@@ -16,7 +16,8 @@ const A = () => ({
16
16
  {
17
17
  code: "featureA",
18
18
  description: "",
19
- numericOrder: false, options: [
19
+ numericOrder: false,
20
+ options: [
20
21
  {
21
22
  code: "optionA",
22
23
  description: "",
@@ -49,13 +50,9 @@ const A = () => ({
49
50
  selOptions: [
50
51
  {
51
52
  code: "!~!",
52
- feature: "featureA",
53
- featDesc: "",
54
53
  next: {
55
54
  optionA: {
56
55
  code: "optionA",
57
- feature: "featureA",
58
- featDesc: "",
59
56
  },
60
57
  },
61
58
  },
@@ -152,18 +149,14 @@ export const getTestProduct = (params) => __awaiter(void 0, void 0, void 0, func
152
149
  }
153
150
  throw new Error("No such part");
154
151
  });
155
- export function getSelOptions(option, feat) {
152
+ export function getSelOptions(option) {
156
153
  if (option === "optionB") {
157
154
  return [
158
155
  {
159
156
  code: "!~!",
160
- feature: feat,
161
- featDesc: "",
162
157
  next: {
163
158
  optionB: {
164
159
  code: "optionB",
165
- feature: feat,
166
- featDesc: "",
167
160
  },
168
161
  },
169
162
  },
@@ -173,13 +166,9 @@ export function getSelOptions(option, feat) {
173
166
  return [
174
167
  {
175
168
  code: "!~!",
176
- feature: feat,
177
- featDesc: "",
178
169
  next: {
179
170
  optionC: {
180
171
  code: "optionC",
181
- feature: feat,
182
- featDesc: "",
183
172
  },
184
173
  },
185
174
  },
@@ -191,9 +180,8 @@ export const cfgProductPriceTest = (testFunc, featureOption) => __awaiter(void 0
191
180
  getProduct: getTestProduct,
192
181
  postValidate: (params, _body) => __awaiter(void 0, void 0, void 0, function* () {
193
182
  const productData = (yield getTestProduct(params)).productData;
194
- const feat = productData.partsData.selOptions[0].feature;
195
183
  if (featureOption !== undefined) {
196
- productData.partsData.selOptions = getSelOptions(featureOption, feat);
184
+ productData.partsData.selOptions = getSelOptions(featureOption);
197
185
  }
198
186
  const validateResponse = {
199
187
  uuid: "",
@@ -90,37 +90,25 @@ const Prd = () => ({
90
90
  selOptions: [
91
91
  {
92
92
  code: "!~!",
93
- feature: "NoUpcharge",
94
- featDesc: "",
95
93
  next: {
96
94
  A: {
97
95
  code: "A",
98
- feature: "NoUpcharge",
99
- featDesc: "",
100
96
  },
101
97
  },
102
98
  },
103
99
  {
104
100
  code: "!~!",
105
- feature: "WithUpcharge",
106
- featDesc: "",
107
101
  next: {
108
102
  A: {
109
103
  code: "A",
110
- feature: "WithUpcharge",
111
- featDesc: "",
112
104
  },
113
105
  },
114
106
  },
115
107
  {
116
108
  code: "!~!",
117
- feature: "WithUpchargeSelectMany",
118
- featDesc: "",
119
109
  next: {
120
110
  A: {
121
111
  code: "A",
122
- feature: "WithUpchargeSelectMany",
123
- featDesc: "",
124
112
  },
125
113
  },
126
114
  },
@@ -1,10 +1,13 @@
1
- import { CatalogueParams, GetProductParams, Model, Prices, ProductData, ProductResponse, SelectedOption, ValidateResponse } from "./CatalogueAPI";
1
+ import { CatalogueParams, GetProductParams, Model, PartsData, Prices, ProductData, ProductResponse, SelectedOption, ValidateResponse } from "./CatalogueAPI";
2
2
  export declare const makeCatalogueKey: (cat: CatalogueParams) => string;
3
3
  export declare const makeProductKey: (cat: CatalogueParams, pKey: string) => string;
4
4
  export declare const makeSelOptionsKey: (options: SelectedOption[]) => string;
5
5
  export declare type RootNodeSource = Model | File;
6
- export declare type CfgProductData = Omit<ProductData, "models"> & {
6
+ export declare type CfgProductData = Omit<Omit<ProductData, "models">, "partsData"> & {
7
7
  models?: RootNodeSource[];
8
+ partsData: Omit<PartsData, "selOptions"> & {
9
+ selOptions: SelectedOption[];
10
+ };
8
11
  };
9
12
  export declare type CfgProductResponse = Omit<ProductResponse, "productData"> & {
10
13
  productData: CfgProductData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "1.3.0-alpha.7",
3
+ "version": "1.4.0-alpha.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@configura/web-utilities": "^1.3.0-alpha.7"
26
+ "@configura/web-utilities": "^1.4.0-alpha.2"
27
27
  },
28
- "gitHead": "1c5c089a31e6662b6da365b7038254e70a1cc8ff"
28
+ "gitHead": "b0d5dbdefc93b2c87298b36d82f6dd32cc2c14e9"
29
29
  }