@configura/web-api 1.6.1-alpha.0 → 1.6.1-alpha.4

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,9 +1,10 @@
1
- import { CfgPath, _CfgProductInternal } from "../CfgProduct.js";
1
+ import { _CfgProductInternal } from "../CfgProduct.js";
2
2
  import { _CfgFeatureInternal } from "../productConfiguration/CfgFeature.js";
3
3
  import { _CfgOptionInternal } from "../productConfiguration/CfgOption.js";
4
4
  import { ProductLoader } from "../productLoader.js";
5
5
  import { SyncGroupsApplyMode } from "./SyncGroupsApplyMode.js";
6
6
  import { OptionCode, SyncCode } from "./SyncGroupsHandler.js";
7
+ import { CfgPath } from "./SyncGroupsPathHelper.js";
7
8
  import { SyncGroupsState } from "./SyncGroupsState.js";
8
9
  /**
9
10
  * A transaction is normally limited to one user interaction. Like opening a product or
@@ -21,21 +22,21 @@ export declare class SyncGroupsTransaction {
21
22
  static make(syncState: SyncGroupsState, updateMode: SyncGroupsApplyMode, product: _CfgProductInternal, productLoader: ProductLoader, assumeNoStartState: boolean): Promise<SyncGroupsTransaction>;
22
23
  /**
23
24
  *
24
- * @param syncState A clone of the original syncState. Replaces the original syncState if nothing fails and the transaction doesn't get aborted
25
+ * @param syncState A clone of the original syncState. Replaces the original syncState if nothing fails and the transaction doesn't get cancelled
25
26
  * @param updateMode
26
27
  * @param productLoader
27
- * @param original The product instance that this transaction will be applied on provided nothing fails and the transaction doesn't get aborted
28
+ * @param original The product instance that this transaction will be applied on provided nothing fails and the transaction doesn't get cancelled
28
29
  * @param target A clone of the original product used to apply the configuration changes to
29
30
  * @param initial A clone of the original product used to track what the original state was. As a safe measure we do not use originalProduct for this, as it might be changed by someone else
30
31
  */
31
32
  private constructor();
32
- private _aborted;
33
+ private _closed;
33
34
  private affectedSelectOneFeatures;
34
35
  private affectedSelectManyOptions;
35
36
  private affectedSelectOneSyncGroups;
36
37
  private affectedSelectManySyncGroupsAndOptions;
37
- get isAborted(): boolean;
38
- abort(): void;
38
+ get isClosed(): boolean;
39
+ close(): void;
39
40
  init(): Promise<boolean>;
40
41
  selectOption(optionPath: CfgPath, on: boolean): Promise<boolean>;
41
42
  addSelectOneFeatureAffected(feature: _CfgFeatureInternal): void;
@@ -7,8 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { assert } from "@configura/web-utilities";
10
11
  import { SelectionType } from "../productConfiguration/CfgFeature.js";
11
12
  import { SyncGroupsApplier } from "./SyncGroupsApplier.js";
13
+ import { SyncGroupsPathHelper } from "./SyncGroupsPathHelper.js";
12
14
  /**
13
15
  * A transaction is normally limited to one user interaction. Like opening a product or
14
16
  * selecting an option. This object is used to keep data for one transaction. In particular
@@ -18,10 +20,10 @@ import { SyncGroupsApplier } from "./SyncGroupsApplier.js";
18
20
  export class SyncGroupsTransaction {
19
21
  /**
20
22
  *
21
- * @param syncState A clone of the original syncState. Replaces the original syncState if nothing fails and the transaction doesn't get aborted
23
+ * @param syncState A clone of the original syncState. Replaces the original syncState if nothing fails and the transaction doesn't get cancelled
22
24
  * @param updateMode
23
25
  * @param productLoader
24
- * @param original The product instance that this transaction will be applied on provided nothing fails and the transaction doesn't get aborted
26
+ * @param original The product instance that this transaction will be applied on provided nothing fails and the transaction doesn't get cancelled
25
27
  * @param target A clone of the original product used to apply the configuration changes to
26
28
  * @param initial A clone of the original product used to track what the original state was. As a safe measure we do not use originalProduct for this, as it might be changed by someone else
27
29
  */
@@ -32,7 +34,7 @@ export class SyncGroupsTransaction {
32
34
  this.original = original;
33
35
  this.target = target;
34
36
  this.initial = initial;
35
- this._aborted = false;
37
+ this._closed = false;
36
38
  this.affectedSelectOneFeatures = new Set();
37
39
  this.affectedSelectManyOptions = new Set();
38
40
  this.affectedSelectOneSyncGroups = new Set();
@@ -44,11 +46,11 @@ export class SyncGroupsTransaction {
44
46
  return t;
45
47
  });
46
48
  }
47
- get isAborted() {
48
- return this._aborted;
49
+ get isClosed() {
50
+ return this._closed;
49
51
  }
50
- abort() {
51
- this._aborted = true;
52
+ close() {
53
+ this._closed = true;
52
54
  }
53
55
  init() {
54
56
  return __awaiter(this, void 0, void 0, function* () {
@@ -57,32 +59,24 @@ export class SyncGroupsTransaction {
57
59
  }
58
60
  selectOption(optionPath, on) {
59
61
  return __awaiter(this, void 0, void 0, function* () {
60
- const targetOption = this.target.getOptionFromPath(optionPath);
62
+ const targetOption = SyncGroupsPathHelper.getOptionFromPath(optionPath, this.target);
61
63
  return yield SyncGroupsApplier.selectOption(this, targetOption, on);
62
64
  });
63
65
  }
64
66
  addSelectOneFeatureAffected(feature) {
65
- if (feature.selectionType !== SelectionType.SelectOne) {
66
- throw new Error("Can only be used for SelectOne Feature");
67
- }
67
+ assert(feature.selectionType === SelectionType.SelectOne, "Can only be used for SelectOne Feature");
68
68
  this.affectedSelectOneFeatures.add(feature);
69
69
  }
70
70
  addSelectManyOptionAffected(option) {
71
- if (option.parent.selectionType !== SelectionType.SelectMany) {
72
- throw new Error("Can only be used for option in SelectMany Feature");
73
- }
71
+ assert(option.parent.selectionType === SelectionType.SelectMany, "Can only be used for option in SelectMany Feature");
74
72
  this.affectedSelectManyOptions.add(option);
75
73
  }
76
74
  hasSelectOneFeatureBeenAffected(feature) {
77
- if (feature.selectionType !== SelectionType.SelectOne) {
78
- throw new Error("Can only be used for SelectOne Feature");
79
- }
75
+ assert(feature.selectionType === SelectionType.SelectOne, "Can only be used for SelectOne Feature");
80
76
  return this.affectedSelectOneFeatures.has(feature);
81
77
  }
82
78
  hasSelectManyOptionBeenAffected(option) {
83
- if (option.parent.selectionType !== SelectionType.SelectMany) {
84
- throw new Error("Can only be used for option in SelectMany Feature");
85
- }
79
+ assert(option.parent.selectionType === SelectionType.SelectMany, "Can only be used for option in SelectMany Feature");
86
80
  return this.affectedSelectManyOptions.has(option);
87
81
  }
88
82
  addSyncGroupAffectedForSelectOne(syncCode) {
@@ -2,14 +2,16 @@ import { shallowCompareDictionaries } from "@configura/web-utilities";
2
2
  export const makeCatalogueKey = (cat) => `${cat.enterprise}-${cat.prdCat}-${cat.prdCatVersion}-${cat.priceList}-${cat.vendor}`;
3
3
  export const makeProductKey = (cat, pKey) => `${makeCatalogueKey(cat)}-${pKey}`;
4
4
  export const makeSelOptionsKey = (options) => options.reduce((p, option) => {
5
- const { code, next } = option;
6
- p += "_{" + code;
5
+ var _a;
6
+ const { code, numericValue, next } = option;
7
+ p += `_{${code}`;
8
+ p += numericValue === undefined ? "" : `_${numericValue.value}${(_a = numericValue.unit) !== null && _a !== void 0 ? _a : ""}`;
7
9
  if (next === undefined) {
8
10
  return p;
9
11
  }
10
12
  for (const key of Object.keys(next)) {
11
13
  const innerOption = next[key];
12
- p += "_{" + key + "_" + makeSelOptionsKey([innerOption]) + "_}";
14
+ p += `_{${key}_${makeSelOptionsKey([innerOption])}_}`;
13
15
  }
14
16
  p += "_}";
15
17
  return p;
@@ -130,10 +132,10 @@ export function isSameProductRef(left, right) {
130
132
  if (left.refKey !== right.refKey) {
131
133
  return false;
132
134
  }
133
- if (!isSameCatalogueParams(left.catId, right.catId)) {
135
+ if (left.partNumber !== right.partNumber) {
134
136
  return false;
135
137
  }
136
- if (left.partNumber !== right.partNumber) {
138
+ if (!isSameCatalogueParams(left.catId, right.catId)) {
137
139
  return false;
138
140
  }
139
141
  if (left.refDescription !== right.refDescription) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "1.6.1-alpha.0",
3
+ "version": "1.6.1-alpha.4",
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.6.1-alpha.0"
26
+ "@configura/web-utilities": "1.6.1-alpha.4"
27
27
  },
28
- "gitHead": "aa99963ec2c2e4ab4ef1795e7ad6204fef31da75"
28
+ "gitHead": "e4dc2f02eff0ea5b4b69fa14e3ae456f505b3e58"
29
29
  }