@configura/web-api 1.6.0-alpha.0 → 1.6.0-iotest.0
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.
- package/dist/CfgProduct.d.ts +12 -31
- package/dist/CfgProduct.js +41 -130
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/CfgHistoryManager.d.ts +30 -0
- package/dist/io/CfgHistoryManager.js +62 -0
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +10 -0
- package/dist/io/CfgHistoryToProdConfConnector.js +18 -0
- package/dist/io/CfgIOManager.d.ts +29 -0
- package/dist/io/CfgIOManager.js +89 -0
- package/dist/io/CfgIOProdConfConnector.d.ts +31 -0
- package/dist/io/CfgIOProdConfConnector.js +100 -0
- package/dist/io/CfgWindowMessageManager.d.ts +13 -0
- package/dist/io/CfgWindowMessageManager.js +28 -0
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +13 -0
- package/dist/io/CfgWindowMessageToProdConfConnector.js +17 -0
- package/dist/productConfiguration/CfgFeature.d.ts +2 -5
- package/dist/productConfiguration/CfgFeature.js +7 -44
- package/dist/productConfiguration/CfgOption.d.ts +1 -12
- package/dist/productConfiguration/CfgOption.js +3 -30
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +4 -5
- package/dist/productConfiguration/CfgProductConfiguration.js +8 -26
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +95 -24
- package/dist/tests/testData/testDataCachedGetProduct.js +19 -8
- package/dist/tests/testData/testDataProductAggregatedPrice.js +23 -12
- package/dist/tests/testData/testDataUpcharge.js +48 -16
- package/dist/utilitiesCatalogueData.js +4 -3
- package/package.json +3 -3
- package/dist/syncGroups/SyncGroupsApplier.d.ts +0 -20
- package/dist/syncGroups/SyncGroupsApplier.js +0 -518
- package/dist/syncGroups/SyncGroupsApplyMode.d.ts +0 -15
- package/dist/syncGroups/SyncGroupsApplyMode.js +0 -15
- package/dist/syncGroups/SyncGroupsHandler.d.ts +0 -30
- package/dist/syncGroups/SyncGroupsHandler.js +0 -71
- package/dist/syncGroups/SyncGroupsState.d.ts +0 -20
- package/dist/syncGroups/SyncGroupsState.js +0 -61
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +0 -50
- package/dist/syncGroups/SyncGroupsTransaction.js +0 -106
- package/dist/tests/testData/testDataOptions.d.ts +0 -13
- package/dist/tests/testData/testDataOptions.js +0 -60
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Is used to keep track of the current value of the SyncGroups. Is fully separated between
|
|
3
|
-
* SelectOne and SelectMany as Features of the two types are synced separately.
|
|
4
|
-
*/
|
|
5
|
-
export class SyncGroupsState {
|
|
6
|
-
constructor() {
|
|
7
|
-
this._selectOne = new Map();
|
|
8
|
-
this._selectMany = new Map();
|
|
9
|
-
}
|
|
10
|
-
clone() {
|
|
11
|
-
const result = new SyncGroupsState();
|
|
12
|
-
result.setFrom(this);
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Replaces the current state
|
|
17
|
-
*/
|
|
18
|
-
setFrom(other) {
|
|
19
|
-
this._selectOne.clear();
|
|
20
|
-
this._selectMany.clear();
|
|
21
|
-
for (const [k, v] of other._selectOne) {
|
|
22
|
-
this._selectOne.set(k, v);
|
|
23
|
-
}
|
|
24
|
-
for (const [sourceSyncCode, sourceOptionToSelected] of other._selectMany) {
|
|
25
|
-
const targetOptionToSelected = new Map();
|
|
26
|
-
for (const [sourceOptionCode, sourceIsSelected] of sourceOptionToSelected) {
|
|
27
|
-
targetOptionToSelected.set(sourceOptionCode, sourceIsSelected);
|
|
28
|
-
}
|
|
29
|
-
this._selectMany.set(sourceSyncCode, targetOptionToSelected);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
setForSelectOne(syncCode, optionCode) {
|
|
33
|
-
this._selectOne.set(syncCode, optionCode);
|
|
34
|
-
this.logDebug();
|
|
35
|
-
}
|
|
36
|
-
setForSelectMany(syncCode, optionCode, selected) {
|
|
37
|
-
let forSyncCode = this._selectMany.get(syncCode);
|
|
38
|
-
if (forSyncCode === undefined) {
|
|
39
|
-
forSyncCode = new Map();
|
|
40
|
-
this._selectMany.set(syncCode, forSyncCode);
|
|
41
|
-
}
|
|
42
|
-
forSyncCode.set(optionCode, selected);
|
|
43
|
-
this.logDebug();
|
|
44
|
-
}
|
|
45
|
-
getForSelectOne(syncCode) {
|
|
46
|
-
return this._selectOne.get(syncCode);
|
|
47
|
-
}
|
|
48
|
-
getForSelectMany(syncCode, optionCode) {
|
|
49
|
-
var _a;
|
|
50
|
-
return (_a = this._selectMany.get(syncCode)) === null || _a === void 0 ? void 0 : _a.get(optionCode);
|
|
51
|
-
}
|
|
52
|
-
logDebug() {
|
|
53
|
-
console.table(Array.from(this._selectOne.entries()));
|
|
54
|
-
console.table(Array.from(this._selectMany.entries()).reduce((a, [groupCode, optionCodeToSelected]) => {
|
|
55
|
-
for (const [optionCode, selected] of optionCodeToSelected) {
|
|
56
|
-
a.push([groupCode, optionCode, selected]);
|
|
57
|
-
}
|
|
58
|
-
return a;
|
|
59
|
-
}, []));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { CfgPath, _CfgProductInternal } from "../CfgProduct.js";
|
|
2
|
-
import { _CfgFeatureInternal } from "../productConfiguration/CfgFeature.js";
|
|
3
|
-
import { _CfgOptionInternal } from "../productConfiguration/CfgOption.js";
|
|
4
|
-
import { ProductLoader } from "../productLoader.js";
|
|
5
|
-
import { SyncGroupsApplyMode } from "./SyncGroupsApplyMode.js";
|
|
6
|
-
import { OptionCode, SyncCode } from "./SyncGroupsHandler.js";
|
|
7
|
-
import { SyncGroupsState } from "./SyncGroupsState.js";
|
|
8
|
-
/**
|
|
9
|
-
* A transaction is normally limited to one user interaction. Like opening a product or
|
|
10
|
-
* selecting an option. This object is used to keep data for one transaction. In particular
|
|
11
|
-
* what Features and what SyncGroups have been affected in the transaction. This is a means
|
|
12
|
-
* to eliminate the risk of infinite loops.
|
|
13
|
-
*/
|
|
14
|
-
export declare class SyncGroupsTransaction {
|
|
15
|
-
readonly syncState: SyncGroupsState;
|
|
16
|
-
readonly updateMode: SyncGroupsApplyMode;
|
|
17
|
-
readonly productLoader: ProductLoader;
|
|
18
|
-
readonly original: _CfgProductInternal;
|
|
19
|
-
readonly target: _CfgProductInternal;
|
|
20
|
-
readonly initial: _CfgProductInternal | undefined;
|
|
21
|
-
static make(syncState: SyncGroupsState, updateMode: SyncGroupsApplyMode, product: _CfgProductInternal, productLoader: ProductLoader, assumeNoStartState: boolean): Promise<SyncGroupsTransaction>;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
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 updateMode
|
|
26
|
-
* @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 target A clone of the original product used to apply the configuration changes to
|
|
29
|
-
* @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
|
-
private constructor();
|
|
32
|
-
private _aborted;
|
|
33
|
-
private affectedSelectOneFeatures;
|
|
34
|
-
private affectedSelectManyOptions;
|
|
35
|
-
private affectedSelectOneSyncGroups;
|
|
36
|
-
private affectedSelectManySyncGroupsAndOptions;
|
|
37
|
-
get isAborted(): boolean;
|
|
38
|
-
abort(): void;
|
|
39
|
-
init(): Promise<boolean>;
|
|
40
|
-
selectOption(optionPath: CfgPath, on: boolean): Promise<boolean>;
|
|
41
|
-
addSelectOneFeatureAffected(feature: _CfgFeatureInternal): void;
|
|
42
|
-
addSelectManyOptionAffected(option: _CfgOptionInternal): void;
|
|
43
|
-
hasSelectOneFeatureBeenAffected(feature: _CfgFeatureInternal): boolean;
|
|
44
|
-
hasSelectManyOptionBeenAffected(option: _CfgOptionInternal): boolean;
|
|
45
|
-
addSyncGroupAffectedForSelectOne(syncCode: SyncCode): void;
|
|
46
|
-
addSyncGroupAffectedForSelectMany(syncCode: SyncCode, optionCode: OptionCode): void;
|
|
47
|
-
isSyncGroupAffectedForSelectOne(syncCode: SyncCode): boolean;
|
|
48
|
-
isSyncGroupAffectedForSelectMany(syncCode: SyncCode, optionCode: OptionCode): boolean;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=SyncGroupsTransaction.d.ts.map
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { SelectionType } from "../productConfiguration/CfgFeature.js";
|
|
11
|
-
import { SyncGroupsApplier } from "./SyncGroupsApplier.js";
|
|
12
|
-
/**
|
|
13
|
-
* A transaction is normally limited to one user interaction. Like opening a product or
|
|
14
|
-
* selecting an option. This object is used to keep data for one transaction. In particular
|
|
15
|
-
* what Features and what SyncGroups have been affected in the transaction. This is a means
|
|
16
|
-
* to eliminate the risk of infinite loops.
|
|
17
|
-
*/
|
|
18
|
-
export class SyncGroupsTransaction {
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param syncState A clone of the original syncState. Replaces the original syncState if nothing fails and the transaction doesn't get aborted
|
|
22
|
-
* @param updateMode
|
|
23
|
-
* @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
|
|
25
|
-
* @param target A clone of the original product used to apply the configuration changes to
|
|
26
|
-
* @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
|
-
*/
|
|
28
|
-
constructor(syncState, updateMode, productLoader, original, target, initial) {
|
|
29
|
-
this.syncState = syncState;
|
|
30
|
-
this.updateMode = updateMode;
|
|
31
|
-
this.productLoader = productLoader;
|
|
32
|
-
this.original = original;
|
|
33
|
-
this.target = target;
|
|
34
|
-
this.initial = initial;
|
|
35
|
-
this._aborted = false;
|
|
36
|
-
this.affectedSelectOneFeatures = new Set();
|
|
37
|
-
this.affectedSelectManyOptions = new Set();
|
|
38
|
-
this.affectedSelectOneSyncGroups = new Set();
|
|
39
|
-
this.affectedSelectManySyncGroupsAndOptions = new Map();
|
|
40
|
-
}
|
|
41
|
-
static make(syncState, updateMode, product, productLoader, assumeNoStartState) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const t = new this(syncState.clone(), updateMode, productLoader, product, yield product.clone(), assumeNoStartState ? undefined : yield product.clone());
|
|
44
|
-
return t;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
get isAborted() {
|
|
48
|
-
return this._aborted;
|
|
49
|
-
}
|
|
50
|
-
abort() {
|
|
51
|
-
this._aborted = true;
|
|
52
|
-
}
|
|
53
|
-
init() {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
return yield SyncGroupsApplier.init(this);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
selectOption(optionPath, on) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const targetOption = this.target.getOptionFromPath(optionPath);
|
|
61
|
-
return yield SyncGroupsApplier.selectOption(this, targetOption, on);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
addSelectOneFeatureAffected(feature) {
|
|
65
|
-
if (feature.selectionType !== SelectionType.SelectOne) {
|
|
66
|
-
throw new Error("Can only be used for SelectOne Feature");
|
|
67
|
-
}
|
|
68
|
-
this.affectedSelectOneFeatures.add(feature);
|
|
69
|
-
}
|
|
70
|
-
addSelectManyOptionAffected(option) {
|
|
71
|
-
if (option.parent.selectionType !== SelectionType.SelectMany) {
|
|
72
|
-
throw new Error("Can only be used for option in SelectMany Feature");
|
|
73
|
-
}
|
|
74
|
-
this.affectedSelectManyOptions.add(option);
|
|
75
|
-
}
|
|
76
|
-
hasSelectOneFeatureBeenAffected(feature) {
|
|
77
|
-
if (feature.selectionType !== SelectionType.SelectOne) {
|
|
78
|
-
throw new Error("Can only be used for SelectOne Feature");
|
|
79
|
-
}
|
|
80
|
-
return this.affectedSelectOneFeatures.has(feature);
|
|
81
|
-
}
|
|
82
|
-
hasSelectManyOptionBeenAffected(option) {
|
|
83
|
-
if (option.parent.selectionType !== SelectionType.SelectMany) {
|
|
84
|
-
throw new Error("Can only be used for option in SelectMany Feature");
|
|
85
|
-
}
|
|
86
|
-
return this.affectedSelectManyOptions.has(option);
|
|
87
|
-
}
|
|
88
|
-
addSyncGroupAffectedForSelectOne(syncCode) {
|
|
89
|
-
this.affectedSelectOneSyncGroups.add(syncCode);
|
|
90
|
-
}
|
|
91
|
-
addSyncGroupAffectedForSelectMany(syncCode, optionCode) {
|
|
92
|
-
let forSyncCode = this.affectedSelectManySyncGroupsAndOptions.get(syncCode);
|
|
93
|
-
if (forSyncCode === undefined) {
|
|
94
|
-
forSyncCode = new Set();
|
|
95
|
-
this.affectedSelectManySyncGroupsAndOptions.set(syncCode, forSyncCode);
|
|
96
|
-
}
|
|
97
|
-
forSyncCode.add(optionCode);
|
|
98
|
-
}
|
|
99
|
-
isSyncGroupAffectedForSelectOne(syncCode) {
|
|
100
|
-
return this.affectedSelectOneSyncGroups.has(syncCode);
|
|
101
|
-
}
|
|
102
|
-
isSyncGroupAffectedForSelectMany(syncCode, optionCode) {
|
|
103
|
-
var _a;
|
|
104
|
-
return ((_a = this.affectedSelectManySyncGroupsAndOptions.get(syncCode)) === null || _a === void 0 ? void 0 : _a.has(optionCode)) === true;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Option, SelectedOption } from "../../CatalogueAPI.js";
|
|
2
|
-
export declare function addDefaultsToMockSelectedOption(root: SelectedOption, optionCodeToAdd: string | undefined, optionCodesToRemove: string[], unlessOptionCodes: string[]): void;
|
|
3
|
-
export declare const letterOptionCodeA = "optA";
|
|
4
|
-
export declare const letterOptionCodeB = "optB";
|
|
5
|
-
export declare const letterOptionCodeC = "optC";
|
|
6
|
-
export declare const letterOptionCodeD = "optD";
|
|
7
|
-
export declare const letterOptionCodeE = "optE";
|
|
8
|
-
export declare const letterOptionCodeF = "optF";
|
|
9
|
-
export declare const letterOptions: Option[];
|
|
10
|
-
export declare const toggleOptionCodeOff = "optOff";
|
|
11
|
-
export declare const toggleOptionCodeOn = "optOn";
|
|
12
|
-
export declare const toggleOptions: Option[];
|
|
13
|
-
//# sourceMappingURL=testDataOptions.d.ts.map
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
export function addDefaultsToMockSelectedOption(root, optionCodeToAdd, optionCodesToRemove, unlessOptionCodes) {
|
|
2
|
-
let next = root.next;
|
|
3
|
-
if (next === undefined) {
|
|
4
|
-
if (optionCodeToAdd === undefined) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
next = {};
|
|
8
|
-
root.next = next;
|
|
9
|
-
}
|
|
10
|
-
for (const oCode of unlessOptionCodes) {
|
|
11
|
-
if (next[oCode] !== undefined) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
for (const oCode of optionCodesToRemove) {
|
|
16
|
-
delete next[oCode];
|
|
17
|
-
}
|
|
18
|
-
if (optionCodeToAdd === undefined) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
next[optionCodeToAdd] = { code: optionCodeToAdd };
|
|
22
|
-
}
|
|
23
|
-
export const letterOptionCodeA = "optA";
|
|
24
|
-
export const letterOptionCodeB = "optB";
|
|
25
|
-
export const letterOptionCodeC = "optC";
|
|
26
|
-
export const letterOptionCodeD = "optD";
|
|
27
|
-
export const letterOptionCodeE = "optE";
|
|
28
|
-
export const letterOptionCodeF = "optF";
|
|
29
|
-
export const letterOptions = [
|
|
30
|
-
{
|
|
31
|
-
code: letterOptionCodeA,
|
|
32
|
-
description: "",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
code: letterOptionCodeB,
|
|
36
|
-
description: "",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
code: letterOptionCodeC,
|
|
40
|
-
description: "",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
code: letterOptionCodeD,
|
|
44
|
-
description: "",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
code: letterOptionCodeE,
|
|
48
|
-
description: "",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
code: letterOptionCodeF,
|
|
52
|
-
description: "",
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
export const toggleOptionCodeOff = "optOff";
|
|
56
|
-
export const toggleOptionCodeOn = "optOn";
|
|
57
|
-
export const toggleOptions = [
|
|
58
|
-
{ code: toggleOptionCodeOff, description: "" },
|
|
59
|
-
{ code: toggleOptionCodeOn, description: "" },
|
|
60
|
-
];
|