@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,5 +1,5 @@
1
1
  import { LengthUnit, LengthValue, Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { DtoFeature, DtoFeatureConfiguration, DtoFeatureRef, DtoSelectedOption } from "../CatalogueAPI.js";
2
+ import { DtoFeature, DtoFeatureConf, DtoFeatureRef, DtoSelectedOption } from "../CatalogueAPI.js";
3
3
  import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
4
4
  import { CfgFeature, _CfgFeatureInternal } from "./CfgFeature.js";
5
5
  import { ProductConfigurationBubbleMode } from "./CfgOption.js";
@@ -20,6 +20,7 @@ export declare class _CfgProductConfigurationInternal {
20
20
  readonly allRawFeatures: DtoFeature[];
21
21
  readonly parentProduct: _CfgProductInternal;
22
22
  readonly rootProduct: _CfgProductInternal;
23
+ private readonly _initialRootFeatureRefs;
23
24
  static _makeUninitialized(rootFeatureRefs: DtoFeatureRef[], allRawFeatures: DtoFeature[], // Flat packed. All the features that can appear anyplace in the selection tree.
24
25
  parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal): _CfgProductConfigurationInternal;
25
26
  private constructor();
@@ -34,10 +35,12 @@ export declare class _CfgProductConfigurationInternal {
34
35
  _freshRefDescendants(): void;
35
36
  /** Called by child to tell its parent that it has changed. */
36
37
  _childHasChanged: (freshRef: CfgFeature, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
37
- getDtoConfiguration: (includeExtendedData: boolean) => DtoFeatureConfiguration[];
38
+ getDtoConf: (includeExtendedData: boolean) => DtoFeatureConf[];
39
+ getApiSelection: () => DtoSelectedOption[];
38
40
  /**
39
41
  * When used internally the notifications are taken care off by the caller, but if set from
40
42
  * outside we want notifications to bubble all the way to the root.
43
+ * This method will not cause validation calls. Data is assumed to already be validated.
41
44
  */
42
45
  setApiSelection: (selectedOptions: DtoSelectedOption[], bubbleToRoot: boolean) => Promise<boolean>;
43
46
  structureCompare: (other: _CfgProductConfigurationInternal, strictOrder: boolean, descriptionMatch: boolean) => boolean;
@@ -48,6 +51,12 @@ export declare class _CfgProductConfigurationInternal {
48
51
  tryMatchSelection: (other: _CfgProductConfigurationInternal, descriptionMatch: boolean | undefined, validate: boolean) => Promise<boolean>;
49
52
  /** Only selected features. */
50
53
  _getFeaturesWithCode: (code: string) => _CfgFeatureInternal[];
54
+ private _hasRootFeaturesChanged;
55
+ /**
56
+ * True if what root Features are used is not the same as at initial load.
57
+ * This means that functional selection has happened.
58
+ */
59
+ get hasRootFeaturesChanged(): boolean;
51
60
  populateFeatures: (rootFeatureRefs: DtoFeatureRef[]) => void;
52
61
  setStretchReferenceLength: (measureParamCode: string, referenceLength: number | undefined, unit: LengthUnit) => Promise<boolean>;
53
62
  }
@@ -94,12 +103,6 @@ export declare class CfgProductConfiguration {
94
103
  * This method will cause validation calls.
95
104
  */
96
105
  tryMatchSelection: (other: CfgProductConfiguration, descriptionMatch?: boolean) => Promise<boolean>;
97
- getApiSelection: () => DtoSelectedOption[];
98
- /**
99
- * This method does not propagate its selections.
100
- * This method will not cause validation calls. Data is assumed to already be validated.
101
- */
102
- setApiSelection: (selectedOptions: DtoSelectedOption[]) => Promise<boolean>;
103
106
  /**
104
107
  * Set how stretched a certain measure should be measureParamCode is the measure to be
105
108
  * stretched referenceLength is a value relative to the initial length of the measure. If the
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { compareArrays, count, isEqualLength, isLengthUnit, Observable, toError, toLengthUnit, } from "@configura/web-utilities";
11
11
  import { CfgProduct } from "../CfgProduct.js";
12
- import { convertDtoFeatureConfigurationsToSelOptions } from "../ConfigurationConverter.js";
12
+ import { convertDtoFeatureConfsToSelOptions } from "../ConfigurationConverter.js";
13
13
  import { CfgFeature } from "./CfgFeature.js";
14
14
  import { ProductConfigurationBubbleMode } from "./CfgOption.js";
15
15
  import { syncCfgFeatures } from "./utilitiesProductConfiguration.js";
@@ -20,10 +20,11 @@ import { syncCfgFeatures } from "./utilitiesProductConfiguration.js";
20
20
  */
21
21
  export class _CfgProductConfigurationInternal {
22
22
  constructor(allRawFeatures, // Flat packed. All the features that can appear anyplace in the selection tree.
23
- parentProduct, rootProduct) {
23
+ parentProduct, rootProduct, _initialRootFeatureRefs) {
24
24
  this.allRawFeatures = allRawFeatures;
25
25
  this.parentProduct = parentProduct;
26
26
  this.rootProduct = rootProduct;
27
+ this._initialRootFeatureRefs = _initialRootFeatureRefs;
27
28
  this.key = "~";
28
29
  this._rootFeatureRefs = [];
29
30
  this._features = [];
@@ -55,10 +56,12 @@ export class _CfgProductConfigurationInternal {
55
56
  features[i] = freshRef;
56
57
  yield this._notifyAllOfChange(bubbleMode, committed);
57
58
  });
58
- this.getDtoConfiguration = (includeExtendedData) => this._features.map((f) => f._internal.getDtoConfiguration(includeExtendedData));
59
+ this.getDtoConf = (includeExtendedData) => this._features.map((f) => f._internal.getDtoConf(includeExtendedData));
60
+ this.getApiSelection = () => convertDtoFeatureConfsToSelOptions(this.getDtoConf(false), true);
59
61
  /**
60
62
  * When used internally the notifications are taken care off by the caller, but if set from
61
63
  * outside we want notifications to bubble all the way to the root.
64
+ * This method will not cause validation calls. Data is assumed to already be validated.
62
65
  */
63
66
  this.setApiSelection = (selectedOptions, bubbleToRoot) => __awaiter(this, void 0, void 0, function* () {
64
67
  const featuresLength = this._features.length;
@@ -111,8 +114,10 @@ export class _CfgProductConfigurationInternal {
111
114
  agg.push(...feature._internal._getFeaturesWithCode(code));
112
115
  return agg;
113
116
  }, []);
117
+ this._hasRootFeaturesChanged = false;
114
118
  this.populateFeatures = (rootFeatureRefs) => {
115
119
  this._rootFeatureRefs = rootFeatureRefs;
120
+ this._hasRootFeaturesChanged = !compareArrays(this._initialRootFeatureRefs, rootFeatureRefs, (l, r) => l.code === r.code);
116
121
  this._features = syncCfgFeatures(rootFeatureRefs, this._features, this.allRawFeatures, this, this, this.parentProduct, this.rootProduct);
117
122
  };
118
123
  this.setStretchReferenceLength = (measureParamCode, referenceLength, unit) => __awaiter(this, void 0, void 0, function* () {
@@ -196,7 +201,7 @@ export class _CfgProductConfigurationInternal {
196
201
  }
197
202
  static _makeUninitialized(rootFeatureRefs, allRawFeatures, // Flat packed. All the features that can appear anyplace in the selection tree.
198
203
  parentProduct, rootProduct) {
199
- const configuration = new this(allRawFeatures, parentProduct, rootProduct);
204
+ const configuration = new this(allRawFeatures, parentProduct, rootProduct, rootFeatureRefs);
200
205
  configuration.populateFeatures(rootFeatureRefs);
201
206
  return configuration;
202
207
  }
@@ -215,6 +220,13 @@ export class _CfgProductConfigurationInternal {
215
220
  features[i] = CfgFeature._makeNewRefFrom(featureInternal);
216
221
  }
217
222
  }
223
+ /**
224
+ * True if what root Features are used is not the same as at initial load.
225
+ * This means that functional selection has happened.
226
+ */
227
+ get hasRootFeaturesChanged() {
228
+ return this._hasRootFeaturesChanged;
229
+ }
218
230
  }
219
231
  export class CfgProductConfiguration {
220
232
  /**
@@ -233,12 +245,6 @@ export class CfgProductConfiguration {
233
245
  */
234
246
  this.tryMatchSelection = (other, descriptionMatch = false // Match on case insensitive description, not code
235
247
  ) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.tryMatchSelection(other._internal, descriptionMatch, true); });
236
- this.getApiSelection = () => convertDtoFeatureConfigurationsToSelOptions(this._internal.getDtoConfiguration(false), true);
237
- /**
238
- * This method does not propagate its selections.
239
- * This method will not cause validation calls. Data is assumed to already be validated.
240
- */
241
- this.setApiSelection = (selectedOptions) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.setApiSelection(selectedOptions, true); });
242
248
  /**
243
249
  * Set how stretched a certain measure should be measureParamCode is the measure to be
244
250
  * stretched referenceLength is a value relative to the initial length of the measure. If the
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { augmentErrorMessage, Observable } from "@configura/web-utilities";
11
11
  import { dtoExportFormatNames, dtoRenderFormatNames, } from "../CatalogueAPI.js";
12
+ import { convertDtoProductConfToV1 } from "../ConfigurationConverter.js";
12
13
  import { isExportFormat, isRenderFormat } from "./formats.js";
13
14
  export class _TaskHandlerInternal {
14
15
  constructor(api) {
@@ -175,7 +176,7 @@ export class Task {
175
176
  this.taskHandler.removeTask(this);
176
177
  };
177
178
  this._productParams = product.prodParams;
178
- this._apiSelection = product.getApiSelection();
179
+ this._apiSelection = convertDtoProductConfToV1(product.getDtoConf());
179
180
  if (getPreviewUrl !== undefined) {
180
181
  void getPreviewUrl().then((dataUrl) => {
181
182
  this._previewUrl = dataUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "2.0.0-alpha.14",
3
+ "version": "2.0.0-alpha.17",
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": "2.0.0-alpha.14"
26
+ "@configura/web-utilities": "2.0.0-alpha.17"
27
27
  },
28
- "gitHead": "b3d0439069dc8cca134143d00fcd2f964525ceca"
28
+ "gitHead": "7894d44db1eb25eab4affba49513cc56ac83fd75"
29
29
  }