@configura/web-api 2.0.0-alpha.14 → 2.0.0-alpha.17

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.
@@ -1,3 +1,8 @@
1
+ /** AdditionalProductConf */
2
+ export interface DtoAdditionalProductConf extends DtoProductConf {
3
+ refKey: string;
4
+ selected: boolean;
5
+ }
1
6
  /** AdditionalProductConfiguration */
2
7
  export interface DtoAdditionalProductConfiguration {
3
8
  refKey?: string;
@@ -5,11 +10,6 @@ export interface DtoAdditionalProductConfiguration {
5
10
  selOptions: Array<DtoSelectedOption>;
6
11
  additionalProducts?: Array<DtoAdditionalProductConfiguration>;
7
12
  }
8
- /** AdditionalProductConfigurationV2 */
9
- export interface DtoAdditionalProductConfigurationV2 extends DtoProductConfiguration {
10
- refKey: string;
11
- selected: boolean;
12
- }
13
13
  /** AdditionalProductRef */
14
14
  export interface DtoAdditionalProductRef {
15
15
  refKey: string;
@@ -52,7 +52,7 @@ export interface DtoCatalogueParams extends DtoCatalogueParamsWithoutCid {
52
52
  export interface DtoCatalogueParamsWithLang extends DtoCatalogueParams {
53
53
  lang: string;
54
54
  }
55
- /** CatalogueParamsWithoutCid */
55
+ /** CatalogueParamsWithoutCid - To identify one catalogue the Portfolio ID CID is needed in addition to the parameters in this object. However as of now CID is not used in API calls and therefore this version without CID is needed. */
56
56
  export interface DtoCatalogueParamsWithoutCid {
57
57
  enterprise: string;
58
58
  prdCat: string;
@@ -127,12 +127,12 @@ export interface DtoFeature {
127
127
  syncGroup?: DtoSyncGroup;
128
128
  unit?: string;
129
129
  }
130
- /** FeatureConfiguration */
131
- export interface DtoFeatureConfiguration {
130
+ /** FeatureConf */
131
+ export interface DtoFeatureConf {
132
132
  code: string;
133
133
  groupCode?: string;
134
134
  unit?: string;
135
- options?: Array<DtoOptionConfiguration>;
135
+ options?: Array<DtoOptionConf>;
136
136
  }
137
137
  /** FeatureRef */
138
138
  export interface DtoFeatureRef {
@@ -248,12 +248,12 @@ export interface DtoOption {
248
248
  upcharge?: number;
249
249
  priceCodes?: Array<string>;
250
250
  }
251
- /** OptionConfiguration */
252
- export interface DtoOptionConfiguration {
251
+ /** OptionConf */
252
+ export interface DtoOptionConf {
253
253
  code: string;
254
254
  selected: boolean;
255
255
  numericValue?: DtoValueWithUnit;
256
- features?: Array<DtoFeatureConfiguration>;
256
+ features?: Array<DtoFeatureConf>;
257
257
  }
258
258
  /** Orientation */
259
259
  export interface DtoOrientation {
@@ -353,10 +353,10 @@ export interface DtoProductCatalogueInfo {
353
353
  exchangeRate: number;
354
354
  lastModified: string;
355
355
  }
356
- /** ProductConfiguration */
357
- export interface DtoProductConfiguration {
358
- features?: Array<DtoFeatureConfiguration>;
359
- additionalProducts?: Array<DtoAdditionalProductConfigurationV2>;
356
+ /** ProductConf - This is intended to eventually supersede AdditionalProductConfiguration as the format for sending/receiving how a Product is configured. */
357
+ export interface DtoProductConf {
358
+ features?: Array<DtoFeatureConf>;
359
+ additionalProducts?: Array<DtoAdditionalProductConf>;
360
360
  prodParams?: DtoProductParamsWithLang;
361
361
  }
362
362
  /** ProductData */
@@ -1,5 +1,5 @@
1
1
  import { AggregatedLoadingObservable, LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParams, DtoMeasureParam, DtoMtrlApplication, DtoPrices, DtoProductConfiguration, DtoProductParamsWithLang, DtoTransform } from "./CatalogueAPI.js";
2
+ import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParams, DtoMeasureParam, DtoMtrlApplication, DtoPrices, DtoProductConf, DtoProductParamsWithLang, DtoTransform } from "./CatalogueAPI.js";
3
3
  import { CfgMeasureDefinition } from "./CfgMeasure.js";
4
4
  import { _CfgFeatureInternal } from "./productConfiguration/CfgFeature.js";
5
5
  import { ProductConfigurationBubbleMode } from "./productConfiguration/CfgOption.js";
@@ -93,8 +93,15 @@ export declare class _CfgProductInternal {
93
93
  get selected(): boolean;
94
94
  readonly isAdditionalProduct: boolean;
95
95
  clone(parent?: _CfgProductInternal, root?: _CfgProductInternal): Promise<_CfgProductInternal>;
96
+ /** Mark this and its descendants as destroyed and remove all listeners */
96
97
  destroy: () => void;
98
+ /**
99
+ * Internal use. Used when this product is an additional product, and
100
+ * changing a parent product has made the settings for this product
101
+ * change.
102
+ */
97
103
  _updateAdditionalProdRef(p: DtoAdditionalProductRef): void;
104
+ get hasRootFeaturesChanged(): boolean;
98
105
  get description(): string | undefined;
99
106
  get rootNodeSources(): RootNodeSource[] | undefined;
100
107
  get mtrlApplications(): DtoMtrlApplication[] | undefined;
@@ -136,8 +143,8 @@ export declare class _CfgProductInternal {
136
143
  _additionalProductHasChanged: (freshRef: CfgProduct, bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
137
144
  /** Called by the configuration to tell its parent that it has changed. */
138
145
  _configurationHasChanged: (freshRef: CfgProductConfiguration, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
139
- getDtoConfiguration: (includeExtendedData: boolean, includeProductParams: boolean) => DtoProductConfiguration;
140
- setDtoConfiguration: (s: DtoProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
146
+ getDtoConf: (includeExtendedData: boolean, includeProductParams: boolean) => DtoProductConf;
147
+ setDtoConf: (s: DtoProductConf, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
141
148
  setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
142
149
  copyFrom: (source: _CfgProductInternal, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
143
150
  private _setApiSelectionWithOtherProduct;
@@ -218,6 +225,18 @@ export declare class CfgProduct {
218
225
  * assumed to always be legal.
219
226
  */
220
227
  setSelected: (v: boolean) => Promise<boolean>;
228
+ /**
229
+ * Functional selection is a Catalogues feature where selecting Options on Features result in that you
230
+ * "jump" to another Product as a result of the Validate call. You normally do not notice that a functional
231
+ * selection has occurred except for the styleNr changing. Functional selection can change which Features
232
+ * from the original product call are used as root Features. This can in turn affect if serialized
233
+ * configuration can be applied or not.
234
+ *
235
+ * The SDK can currently only apply serialized configuration if the list of root Features has not changed.
236
+ * For this reason, when functional selection has happened, extracting data for external systems might work
237
+ * well, but reapplying back into Stage will probably fail.
238
+ */
239
+ get hasRootFeaturesChanged(): boolean;
221
240
  get rawProductData(): CfgProductData;
222
241
  get uuid(): string;
223
242
  get unit(): LengthUnit;
@@ -254,11 +273,43 @@ export declare class CfgProduct {
254
273
  * Gets what selections has been made on the product, recursively including product
255
274
  * configuration, optional products and additional products. Used when a full view of all
256
275
  * selections on a product is needed, such as when doing Render or Export.
276
+ * @deprecated getDtoConf provides a newer format.
277
+ * @see getDtoConf
257
278
  */
258
279
  getApiSelection: () => DtoAdditionalProductConfiguration;
259
- getDtoConfiguration: (includeExtendedData?: boolean, includeProductParams?: boolean) => DtoProductConfiguration;
260
- setDtoConfiguration: (s: DtoProductConfiguration, doValidate?: boolean) => Promise<boolean>;
261
- setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate?: boolean) => Promise<boolean>;
280
+ /**
281
+ * Applies the configuration (selections) in the passed object onto the product recursively
282
+ * including product configuration, optional products and additional products.
283
+ * @param doValidate Makes a server side validation call. These are necessary to ensure that
284
+ * the right models are loaded.
285
+ * @deprecated setDtoConf uses a newer format.
286
+ */
287
+ setApiSelection: (configuration: DtoAdditionalProductConfiguration, doValidate?: boolean) => Promise<boolean>;
288
+ /**
289
+ * A newer alternative version of getApiSelection. This returns the configuration (selections)
290
+ * on the product, recursively including product configuration, optional products and additional
291
+ * products.
292
+ * This version has the following advantages over getApiSelection:
293
+ * - The format is clearer, designed to be readable
294
+ * - Makes less assumptions about the structure in the Product being unchanging over time. In
295
+ * particular, the Feature codes are included in the data, so that changes to what Features
296
+ * are used in a Product is less likely to lead to unexpected results.
297
+ * - You can request ExtendedData and/or ProductParams to be included in the result. This extra
298
+ * data is ignored when passed back into the API, but it can be very useful for external
299
+ * applications.
300
+ * The other version (getApiSelection) has the advantage of using a format directly compatible with the API:s.
301
+ * @param includeExtendedData Includes extra data which is not an actual part of the configuration,
302
+ * i.e. units and groupCodes
303
+ * @param includeProductParams Includes what Product this was generated for, and the same for any
304
+ * Additional Products.
305
+ */
306
+ getDtoConf: (includeExtendedData?: boolean, includeProductParams?: boolean) => DtoProductConf;
307
+ /**
308
+ * A newer alternative version of setApiSelection.
309
+ * @param doValidate Makes a server side validation call. These are necessary to ensure that
310
+ * the right models are loaded.
311
+ */
312
+ setDtoConf: (configuration: DtoProductConf, doValidate?: boolean) => Promise<boolean>;
262
313
  listenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
263
314
  stopListenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
264
315
  stopAllListenForChange: () => void;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { AggregatedLoadingObservable, assert, assertDefined, augmentErrorMessage, compareArrays, count, Observable, toLengthUnit, } from "@configura/web-utilities";
11
11
  import { CfgMeasureDefinition } from "./CfgMeasure.js";
12
- import { convertDtoProductConfigurationToV1 } from "./ConfigurationConverter.js";
12
+ import { convertDtoProductConfToV1 } from "./ConfigurationConverter.js";
13
13
  import { ProductConfigurationBubbleMode } from "./productConfiguration/CfgOption.js";
14
14
  import { CfgProductConfiguration } from "./productConfiguration/CfgProductConfiguration.js";
15
15
  import { collectAdditionalProductRefs } from "./productConfiguration/utilitiesProductConfiguration.js";
@@ -67,11 +67,13 @@ export class _CfgProductInternal {
67
67
  this._destroyed = false;
68
68
  this.additionalProducts = [];
69
69
  this.changeObservable = new Observable();
70
+ /** Mark this and its descendants as destroyed and remove all listeners */
70
71
  this.destroy = () => {
72
+ var _a;
71
73
  this._destroyed = true;
72
74
  this.changeObservable.stopAllListen();
73
75
  this.configuration.stopAllListenForChange();
74
- for (const additionalProduct of this.additionalProducts || []) {
76
+ for (const additionalProduct of (_a = this.additionalProducts) !== null && _a !== void 0 ? _a : []) {
75
77
  additionalProduct.destroy();
76
78
  }
77
79
  };
@@ -140,9 +142,9 @@ export class _CfgProductInternal {
140
142
  return;
141
143
  }
142
144
  });
143
- this.getDtoConfiguration = (includeExtendedData, includeProductParams) => {
145
+ this.getDtoConf = (includeExtendedData, includeProductParams) => {
144
146
  const conf = {};
145
- const features = this.configuration._internal.getDtoConfiguration(includeExtendedData);
147
+ const features = this.configuration._internal.getDtoConf(includeExtendedData);
146
148
  if (0 < features.length) {
147
149
  conf.features = features;
148
150
  }
@@ -151,7 +153,7 @@ export class _CfgProductInternal {
151
153
  }
152
154
  const additionalProducts = this.additionalProducts;
153
155
  if (0 < additionalProducts.length) {
154
- conf.additionalProducts = additionalProducts.map((p) => p._internal.getDtoConfiguration(includeExtendedData, includeProductParams));
156
+ conf.additionalProducts = additionalProducts.map((p) => p._internal.getDtoConf(includeExtendedData, includeProductParams));
155
157
  }
156
158
  if (this.isAdditionalProduct) {
157
159
  const refKey = this.refKey;
@@ -164,14 +166,14 @@ export class _CfgProductInternal {
164
166
  }
165
167
  return conf;
166
168
  };
167
- this.setDtoConfiguration = (s, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
168
- return yield this.setApiSelection(convertDtoProductConfigurationToV1(s), doValidate, productLoaderForGroupedLoad);
169
+ this.setDtoConf = (s, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
170
+ return yield this.setApiSelection(convertDtoProductConfToV1(s), doValidate, productLoaderForGroupedLoad);
169
171
  });
170
172
  this.setApiSelection = (s, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
171
173
  return yield this._setApiSelectionWithOtherProduct(s, doValidate, productLoaderForGroupedLoad, undefined);
172
174
  });
173
175
  this.copyFrom = (source, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
174
- return yield this._setApiSelectionWithOtherProduct(convertDtoProductConfigurationToV1(source.getDtoConfiguration(false, false)), doValidate, productLoaderForGroupedLoad, source);
176
+ return yield this._setApiSelectionWithOtherProduct(convertDtoProductConfToV1(source.getDtoConf(false, false)), doValidate, productLoaderForGroupedLoad, source);
175
177
  });
176
178
  this._setApiSelectionWithOtherProduct = (s, doValidate, productLoaderForGroupedLoad, sourceProduct) => __awaiter(this, void 0, void 0, function* () {
177
179
  // Wrap with cache will make getProduct for this function call use the same server call
@@ -312,7 +314,7 @@ export class _CfgProductInternal {
312
314
  const token = this.loadingObservable.startChildLoading();
313
315
  this._revalidateInProgressToken = token;
314
316
  try {
315
- const response = yield productLoader.postValidate(correctDefaultsOnCatalogueParams(this.prodParams), { selOptions: configuration.getApiSelection() });
317
+ const response = yield productLoader.postValidate(correctDefaultsOnCatalogueParams(this.prodParams), { selOptions: configuration._internal.getApiSelection() });
316
318
  // The revalidateInProgressToken is used to know if some other revalidate
317
319
  // call has happened after this call, thereby making this call obsolete.
318
320
  // This is a bit crude in that it does not actually cancel previous validate
@@ -350,7 +352,7 @@ export class _CfgProductInternal {
350
352
  return true;
351
353
  }
352
354
  catch (e) {
353
- throw augmentErrorMessage(e, "Validate product configuration request failure");
355
+ throw augmentErrorMessage(e, `Validate product configuration request (${this.prodParams.partNumber}) failure`);
354
356
  }
355
357
  finally {
356
358
  this.loadingObservable.stopChildLoading(token);
@@ -435,7 +437,7 @@ export class _CfgProductInternal {
435
437
  var _a;
436
438
  const p = new _CfgProductInternal(() => {
437
439
  initSuccess(p);
438
- }, initFail, this._productLoaderRaw, this.prodParams, this.settings, this.optional, this.selected, this._configuration.rootFeatureRefs, this._configuration.allRawFeatures, this.uuid, this._rawUnit, this._rawProductData, this.configuration.getApiSelection(), new AggregatedLoadingObservable(), parent, root, this._additionalProductRef, (_a = this._syncGroupHandler) === null || _a === void 0 ? void 0 : _a.clone());
440
+ }, initFail, this._productLoaderRaw, this.prodParams, this.settings, this.optional, this.selected, this._configuration.rootFeatureRefs, this._configuration.allRawFeatures, this.uuid, this._rawUnit, this._rawProductData, this.configuration._internal.getApiSelection(), new AggregatedLoadingObservable(), parent, root, this._additionalProductRef, (_a = this._syncGroupHandler) === null || _a === void 0 ? void 0 : _a.clone());
439
441
  });
440
442
  for (const additionalProduct of this.additionalProducts) {
441
443
  product.additionalProducts.push(CfgProduct._makeNewRefFrom(yield additionalProduct._internal.clone(product, root || product)));
@@ -443,12 +445,21 @@ export class _CfgProductInternal {
443
445
  return product;
444
446
  });
445
447
  }
448
+ /**
449
+ * Internal use. Used when this product is an additional product, and
450
+ * changing a parent product has made the settings for this product
451
+ * change.
452
+ */
446
453
  _updateAdditionalProdRef(p) {
447
454
  this._additionalProductRef = p;
448
455
  if (p.optional !== this.optional) {
449
456
  this._selected = p.optional ? false : undefined;
450
457
  }
451
458
  }
459
+ get hasRootFeaturesChanged() {
460
+ return (this._configuration._internal.hasRootFeaturesChanged ||
461
+ this.additionalProducts.some((p) => p._internal.hasRootFeaturesChanged));
462
+ }
452
463
  get description() {
453
464
  var _a, _b;
454
465
  return (_b = (_a = this._additionalProductRef) === null || _a === void 0 ? void 0 : _a.refDescription) !== null && _b !== void 0 ? _b : this._rawProductData.description;
@@ -611,7 +622,7 @@ prodParams, settings, optional, loadingObservable, parent, root, additionalProdu
611
622
  return product;
612
623
  }
613
624
  catch (e) {
614
- throw augmentErrorMessage(e, "Load product request failure");
625
+ throw augmentErrorMessage(e, `Load product request (${prodParams.partNumber}) failure`);
615
626
  }
616
627
  });
617
628
  export class CfgProduct {
@@ -650,11 +661,43 @@ export class CfgProduct {
650
661
  * Gets what selections has been made on the product, recursively including product
651
662
  * configuration, optional products and additional products. Used when a full view of all
652
663
  * selections on a product is needed, such as when doing Render or Export.
664
+ * @deprecated getDtoConf provides a newer format.
665
+ * @see getDtoConf
666
+ */
667
+ this.getApiSelection = () => convertDtoProductConfToV1(this._internal.getDtoConf(false, false), true);
668
+ /**
669
+ * Applies the configuration (selections) in the passed object onto the product recursively
670
+ * including product configuration, optional products and additional products.
671
+ * @param doValidate Makes a server side validation call. These are necessary to ensure that
672
+ * the right models are loaded.
673
+ * @deprecated setDtoConf uses a newer format.
674
+ */
675
+ this.setApiSelection = (configuration, doValidate = true) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.setApiSelection(configuration, doValidate); });
676
+ /**
677
+ * A newer alternative version of getApiSelection. This returns the configuration (selections)
678
+ * on the product, recursively including product configuration, optional products and additional
679
+ * products.
680
+ * This version has the following advantages over getApiSelection:
681
+ * - The format is clearer, designed to be readable
682
+ * - Makes less assumptions about the structure in the Product being unchanging over time. In
683
+ * particular, the Feature codes are included in the data, so that changes to what Features
684
+ * are used in a Product is less likely to lead to unexpected results.
685
+ * - You can request ExtendedData and/or ProductParams to be included in the result. This extra
686
+ * data is ignored when passed back into the API, but it can be very useful for external
687
+ * applications.
688
+ * The other version (getApiSelection) has the advantage of using a format directly compatible with the API:s.
689
+ * @param includeExtendedData Includes extra data which is not an actual part of the configuration,
690
+ * i.e. units and groupCodes
691
+ * @param includeProductParams Includes what Product this was generated for, and the same for any
692
+ * Additional Products.
693
+ */
694
+ this.getDtoConf = (includeExtendedData = false, includeProductParams = false) => this._internal.getDtoConf(includeExtendedData, includeProductParams);
695
+ /**
696
+ * A newer alternative version of setApiSelection.
697
+ * @param doValidate Makes a server side validation call. These are necessary to ensure that
698
+ * the right models are loaded.
653
699
  */
654
- this.getApiSelection = () => convertDtoProductConfigurationToV1(this._internal.getDtoConfiguration(false, false), true);
655
- this.getDtoConfiguration = (includeExtendedData = false, includeProductParams = false) => this._internal.getDtoConfiguration(includeExtendedData, includeProductParams);
656
- this.setDtoConfiguration = (s, doValidate = true) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.setDtoConfiguration(s, doValidate); });
657
- this.setApiSelection = (s, doValidate = true) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.setApiSelection(s, doValidate); });
700
+ this.setDtoConf = (configuration, doValidate = true) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.setDtoConf(configuration, doValidate); });
658
701
  this.listenForChange = (l) => this._internal.changeObservable.listen(l);
659
702
  this.stopListenForChange = (l) => this._internal.changeObservable.stopListen(l);
660
703
  this.stopAllListenForChange = () => this._internal.changeObservable.stopAllListen();
@@ -733,6 +776,21 @@ export class CfgProduct {
733
776
  get visible() {
734
777
  return this._internal.visible;
735
778
  }
779
+ // A similar text to the one below exists in global-message-managers.md and should be kept in sync.
780
+ /**
781
+ * Functional selection is a Catalogues feature where selecting Options on Features result in that you
782
+ * "jump" to another Product as a result of the Validate call. You normally do not notice that a functional
783
+ * selection has occurred except for the styleNr changing. Functional selection can change which Features
784
+ * from the original product call are used as root Features. This can in turn affect if serialized
785
+ * configuration can be applied or not.
786
+ *
787
+ * The SDK can currently only apply serialized configuration if the list of root Features has not changed.
788
+ * For this reason, when functional selection has happened, extracting data for external systems might work
789
+ * well, but reapplying back into Stage will probably fail.
790
+ */
791
+ get hasRootFeaturesChanged() {
792
+ return this._internal.hasRootFeaturesChanged;
793
+ }
736
794
  get rawProductData() {
737
795
  return this._internal.rawProductData;
738
796
  }
@@ -1,14 +1,14 @@
1
- import { DtoAdditionalProductConfiguration, DtoAdditionalProductConfigurationV2, DtoFeatureConfiguration, DtoProductConfiguration, DtoSelectedOption } from "./CatalogueAPI.js";
2
- export declare const isDtoProductConfigurationAdditional: (value: DtoProductConfiguration) => value is DtoAdditionalProductConfigurationV2;
3
- export declare const convertDtoProductConfigurationToV1: (conf: DtoProductConfiguration, silenceWarnings?: boolean) => DtoAdditionalProductConfiguration;
4
- export declare const convertDtoFeatureConfigurationsToSelOptions: (features: DtoFeatureConfiguration[], silenceWarnings?: boolean) => DtoSelectedOption[];
1
+ import { DtoAdditionalProductConf, DtoAdditionalProductConfiguration, DtoFeatureConf, DtoProductConf, DtoSelectedOption } from "./CatalogueAPI.js";
2
+ export declare const isDtoProductConfAdditional: (value: DtoProductConf) => value is DtoAdditionalProductConf;
3
+ export declare const convertDtoProductConfToV1: (conf: DtoProductConf, silenceWarnings?: boolean) => DtoAdditionalProductConfiguration;
4
+ export declare const convertDtoFeatureConfsToSelOptions: (features: DtoFeatureConf[], silenceWarnings?: boolean) => DtoSelectedOption[];
5
5
  /**
6
6
  * Serializes and compacts the configuration into a format especially suited for URLs
7
7
  */
8
- export declare const dtoProductConfigurationToCompactString: (conf: DtoProductConfiguration) => string;
8
+ export declare const dtoProductConfigurationToCompactString: (conf: DtoProductConf) => string;
9
9
  /**
10
10
  * Deserializes and inflates the configuration from the compacted format
11
11
  */
12
- export declare const compactStringToDtoProductConfiguration: (versionAndConf: string) => DtoProductConfiguration;
13
- export declare const stripExtendedDataFromDtoProductConfiguration: (conf: DtoProductConfiguration) => DtoProductConfiguration;
12
+ export declare const compactStringToDtoProductConf: (versionAndConf: string) => DtoProductConf;
13
+ export declare const stripExtendedDataFromDtoProductConf: (conf: DtoProductConf) => DtoProductConf;
14
14
  //# sourceMappingURL=ConfigurationConverter.d.ts.map
@@ -1,33 +1,33 @@
1
- export const isDtoProductConfigurationAdditional = (value) => "refKey" in value;
1
+ export const isDtoProductConfAdditional = (value) => "refKey" in value;
2
2
  // As this has potential to flood the terminal we only inform once
3
3
  let hasInformedAboutProdParams = false;
4
4
  let hasInformedAboutGroupCode = false;
5
5
  let hasInformedAboutUnit = false;
6
- export const convertDtoProductConfigurationToV1 = (conf, silenceWarnings = false) => {
6
+ export const convertDtoProductConfToV1 = (conf, silenceWarnings = false) => {
7
7
  var _a, _b;
8
8
  if (!silenceWarnings && conf.prodParams !== undefined && !hasInformedAboutProdParams) {
9
9
  hasInformedAboutProdParams = true;
10
- console.info("Incoming DtoProductConfiguration contains prodParams. These will be ignored.");
10
+ console.info("Incoming DtoProductConf contains prodParams. These will be ignored.");
11
11
  }
12
12
  const result = {
13
13
  selOptions: ((_a = conf.features) !== null && _a !== void 0 ? _a : []).map((f) => ({
14
14
  code: "!~!",
15
- next: convertDtoFeatureConfigurationToApiSelection(f, silenceWarnings),
15
+ next: convertDtoFeatureConfToApiSelection(f, silenceWarnings),
16
16
  })),
17
- additionalProducts: ((_b = conf.additionalProducts) !== null && _b !== void 0 ? _b : []).map((p) => convertDtoProductConfigurationToV1(p, silenceWarnings)),
17
+ additionalProducts: ((_b = conf.additionalProducts) !== null && _b !== void 0 ? _b : []).map((p) => convertDtoProductConfToV1(p, silenceWarnings)),
18
18
  selected: true,
19
19
  };
20
- if (isDtoProductConfigurationAdditional(conf)) {
20
+ if (isDtoProductConfAdditional(conf)) {
21
21
  result.refKey = conf.refKey;
22
22
  result.selected = conf.selected;
23
23
  }
24
24
  return result;
25
25
  };
26
- export const convertDtoFeatureConfigurationsToSelOptions = (features, silenceWarnings = false) => (features !== null && features !== void 0 ? features : []).map((f) => ({
26
+ export const convertDtoFeatureConfsToSelOptions = (features, silenceWarnings = false) => (features !== null && features !== void 0 ? features : []).map((f) => ({
27
27
  code: "!~!",
28
- next: convertDtoFeatureConfigurationToApiSelection(f, silenceWarnings),
28
+ next: convertDtoFeatureConfToApiSelection(f, silenceWarnings),
29
29
  }));
30
- const convertDtoFeatureConfigurationToApiSelection = (feature, silenceWarnings) => {
30
+ const convertDtoFeatureConfToApiSelection = (feature, silenceWarnings) => {
31
31
  const { groupCode, options, unit } = feature;
32
32
  if (!silenceWarnings && groupCode !== undefined && !hasInformedAboutGroupCode) {
33
33
  hasInformedAboutGroupCode = true;
@@ -39,13 +39,13 @@ const convertDtoFeatureConfigurationToApiSelection = (feature, silenceWarnings)
39
39
  }
40
40
  const result = {};
41
41
  for (const option of (options !== null && options !== void 0 ? options : []).filter((o) => o.selected)) {
42
- result[option.code] = convertDtoOptionConfigurationToSelectedOption(option, silenceWarnings);
42
+ result[option.code] = convertDtoOptionConfToSelectedOption(option, silenceWarnings);
43
43
  }
44
44
  return result;
45
45
  };
46
- const convertDtoOptionConfigurationToSelectedOption = (option, silenceWarnings) => {
46
+ const convertDtoOptionConfToSelectedOption = (option, silenceWarnings) => {
47
47
  const { features, code, numericValue } = option;
48
- const selectionTrees = (features !== null && features !== void 0 ? features : []).map((f) => convertDtoFeatureConfigurationToApiSelection(f, silenceWarnings));
48
+ const selectionTrees = (features !== null && features !== void 0 ? features : []).map((f) => convertDtoFeatureConfToApiSelection(f, silenceWarnings));
49
49
  const mergedSelectionTree = {};
50
50
  let anyItems = false;
51
51
  for (const selectionTree of selectionTrees) {
@@ -76,7 +76,7 @@ const swapForUrlAdaptedRegex = /[-~_{}"]/g;
76
76
  const shortToLong = new Map();
77
77
  const longToShort = new Map();
78
78
  // The replacement scheme here assumes this will only be used for keys
79
- // in DtoProductConfiguration and the knowledge that it contains no one
79
+ // in DtoProductConf and the knowledge that it contains no one
80
80
  // one char keys.
81
81
  for (const [long, short] of [
82
82
  ["configuration", "c"],
@@ -116,17 +116,17 @@ const jsonStringSwapCharsForUrl = (data) => data.replace(swapForUrlAdaptedRegex,
116
116
  throw new Error(`Unexpected char "${char}" in swap for URL`);
117
117
  }
118
118
  });
119
- const compactDtoProductConfigurationJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => { var _a; return `"${(_a = longToShort.get(key)) !== null && _a !== void 0 ? _a : key}":`; });
120
- const expandDtoProductConfigurationJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => { var _a; return `"${(_a = shortToLong.get(key)) !== null && _a !== void 0 ? _a : key}":`; });
119
+ const compactDtoProductConfJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => { var _a; return `"${(_a = longToShort.get(key)) !== null && _a !== void 0 ? _a : key}":`; });
120
+ const expandDtoProductConfJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => { var _a; return `"${(_a = shortToLong.get(key)) !== null && _a !== void 0 ? _a : key}":`; });
121
121
  /**
122
122
  * Serializes and compacts the configuration into a format especially suited for URLs
123
123
  */
124
124
  export const dtoProductConfigurationToCompactString = (conf) => "v1" +
125
- jsonStringSwapCharsForUrl(compactDtoProductConfigurationJsonKeys(JSON.stringify(conf, undefined, "")));
125
+ jsonStringSwapCharsForUrl(compactDtoProductConfJsonKeys(JSON.stringify(conf, undefined, "")));
126
126
  /**
127
127
  * Deserializes and inflates the configuration from the compacted format
128
128
  */
129
- export const compactStringToDtoProductConfiguration = (versionAndConf) => {
129
+ export const compactStringToDtoProductConf = (versionAndConf) => {
130
130
  const match = versionedRegex.exec(versionAndConf);
131
131
  if (match === null) {
132
132
  throw new Error("Could not match version string");
@@ -138,29 +138,29 @@ export const compactStringToDtoProductConfiguration = (versionAndConf) => {
138
138
  if (conf === "") {
139
139
  throw new Error("No conf found");
140
140
  }
141
- return JSON.parse(expandDtoProductConfigurationJsonKeys(jsonStringSwapCharsForUrl(conf)));
141
+ return JSON.parse(expandDtoProductConfJsonKeys(jsonStringSwapCharsForUrl(conf)));
142
142
  };
143
- export const stripExtendedDataFromDtoProductConfiguration = (conf) => {
143
+ export const stripExtendedDataFromDtoProductConf = (conf) => {
144
144
  var _a, _b;
145
145
  return ({
146
- features: (_a = conf.features) === null || _a === void 0 ? void 0 : _a.map(stripExtendedDataFromDtoFeatureConfiguration),
146
+ features: (_a = conf.features) === null || _a === void 0 ? void 0 : _a.map(stripExtendedDataFromDtoFeatureConf),
147
147
  additionalProducts: (_b = conf.additionalProducts) === null || _b === void 0 ? void 0 : _b.map(stripExtendedDataFromDtoAdditionalProductConfiguration),
148
148
  });
149
149
  };
150
- const stripExtendedDataFromDtoAdditionalProductConfiguration = (conf) => (Object.assign(Object.assign({}, stripExtendedDataFromDtoProductConfiguration(conf)), { refKey: conf.refKey, selected: conf.selected }));
151
- const stripExtendedDataFromDtoFeatureConfiguration = (conf) => {
150
+ const stripExtendedDataFromDtoAdditionalProductConfiguration = (conf) => (Object.assign(Object.assign({}, stripExtendedDataFromDtoProductConf(conf)), { refKey: conf.refKey, selected: conf.selected }));
151
+ const stripExtendedDataFromDtoFeatureConf = (conf) => {
152
152
  var _a;
153
153
  return ({
154
154
  code: conf.code,
155
- options: (_a = conf.options) === null || _a === void 0 ? void 0 : _a.map(stripExtendedDataFromDtoOptionConfiguration),
155
+ options: (_a = conf.options) === null || _a === void 0 ? void 0 : _a.map(stripExtendedDataFromDtoOptionConf),
156
156
  });
157
157
  };
158
- const stripExtendedDataFromDtoOptionConfiguration = (conf) => {
158
+ const stripExtendedDataFromDtoOptionConf = (conf) => {
159
159
  var _a;
160
160
  return ({
161
161
  code: conf.code,
162
162
  selected: conf.selected,
163
163
  numericValue: conf.numericValue,
164
- features: (_a = conf.features) === null || _a === void 0 ? void 0 : _a.map(stripExtendedDataFromDtoFeatureConfiguration),
164
+ features: (_a = conf.features) === null || _a === void 0 ? void 0 : _a.map(stripExtendedDataFromDtoFeatureConf),
165
165
  });
166
166
  };
@@ -2,6 +2,21 @@ import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
2
2
  declare type CfgHistoryManagerMessageData = {
3
3
  initial: boolean;
4
4
  };
5
+ /**
6
+ * How the history is updated.
7
+ * @param DoNotWrite Only listens to initial URL-values.
8
+ * @param Replace Replaces the current history frame at updates.
9
+ * @param Push Adds history frames at updates.
10
+ * @param ReplaceAndUpdateUrl Replaces the current history frame at updates and updates the browser URL
11
+ * @param PushAndUpdateUrl Adds history frames at updates and updates the browser URL
12
+ */
13
+ export declare enum HistoryMode {
14
+ DoNotWrite = 0,
15
+ Replace = 1,
16
+ Push = 2,
17
+ ReplaceAndUpdateUrl = 3,
18
+ PushAndUpdateUrl = 4
19
+ }
5
20
  /**
6
21
  * The collected data used when sending. For history this both contains the message, which is
7
22
  * used as the "state" in the history-frame, and the qsKeyValues, which are query string
@@ -11,7 +26,7 @@ declare type CfgHistoryManagerMessageData = {
11
26
  */
12
27
  export declare type CfgHistoryManagerSendData<D> = {
13
28
  message: D;
14
- useHistoryPush: boolean;
29
+ mode: HistoryMode;
15
30
  qsKeyValues: Map<string, string | undefined>;
16
31
  };
17
32
  /**
@@ -22,6 +37,22 @@ export declare class CfgHistoryManager extends CfgWindowEventManager<"popstate",
22
37
  private static _instance;
23
38
  static get instance(): CfgHistoryManager;
24
39
  private constructor();
40
+ private _aggregatedQsKeyValues;
41
+ private _urlUpdateObservable;
42
+ /**
43
+ * @returns The current browser URL updated with the latest updates from
44
+ * the Connectors.
45
+ */
46
+ getUrl(): string;
47
+ /**
48
+ * Listen for updated URL:s. This doesn't have to mean the URL in the
49
+ * browser has been updated.
50
+ */
51
+ listenForUrl(listener: (url: string) => void): void;
52
+ /**
53
+ * Stop listen.
54
+ */
55
+ stopListenForUrl(listener: (url: string) => void): void;
25
56
  /**
26
57
  * Write to the history
27
58
  */
@@ -47,6 +78,7 @@ export declare class CfgHistoryManager extends CfgWindowEventManager<"popstate",
47
78
  private static _makeUpdatedState;
48
79
  protected readonly eventType = "popstate";
49
80
  protected getDataFromEvent(event: PopStateEvent): unknown;
81
+ static getMessageFromCurrentHistoryState(messageKey: string): unknown | undefined;
50
82
  }
51
83
  export {};
52
84
  //# sourceMappingURL=CfgHistoryManager.d.ts.map