@configura/web-api 2.2.0-alpha.1 → 2.2.0-alpha.3
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/.eslintrc.json +5 -5
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +633 -633
- package/dist/CatalogueAPI.js +312 -312
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +359 -344
- package/dist/CfgProduct.js +1005 -992
- package/dist/CfgReferencePathHelper.d.ts +26 -26
- package/dist/CfgReferencePathHelper.js +26 -26
- package/dist/index.d.ts +24 -24
- package/dist/index.js +24 -24
- package/dist/io/CfgHistoryManager.d.ts +83 -83
- package/dist/io/CfgHistoryManager.js +144 -144
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -21
- package/dist/io/CfgHistoryToProdConfConnector.js +50 -50
- package/dist/io/CfgIOManager.d.ts +53 -53
- package/dist/io/CfgIOManager.js +134 -134
- package/dist/io/CfgIOProdConfConnector.d.ts +54 -54
- package/dist/io/CfgIOProdConfConnector.js +139 -139
- package/dist/io/CfgIOWarningSupplier.d.ts +3 -3
- package/dist/io/CfgIOWarningSupplier.js +1 -1
- package/dist/io/CfgObservableStateManager.d.ts +25 -25
- package/dist/io/CfgObservableStateManager.js +69 -69
- package/dist/io/CfgObservableStateToProdConfConnector.d.ts +15 -15
- package/dist/io/CfgObservableStateToProdConfConnector.js +17 -17
- package/dist/io/CfgWindowEventManager.d.ts +21 -21
- package/dist/io/CfgWindowEventManager.js +38 -38
- package/dist/io/CfgWindowMessageManager.d.ts +40 -40
- package/dist/io/CfgWindowMessageManager.js +91 -91
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +17 -17
- package/dist/io/CfgWindowMessageToProdConfConnector.js +19 -19
- package/dist/io/index.d.ts +8 -8
- package/dist/io/index.js +8 -8
- package/dist/material/CfgMaterialMapping.d.ts +7 -7
- package/dist/material/CfgMaterialMapping.js +181 -181
- package/dist/material/CfgMtrlApplication.d.ts +18 -18
- package/dist/material/CfgMtrlApplication.js +43 -43
- package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
- package/dist/material/CfgMtrlApplicationSource.js +8 -8
- package/dist/material/CfgMtrlSource.d.ts +19 -19
- package/dist/material/CfgMtrlSource.js +40 -40
- package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
- package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
- package/dist/productConfiguration/CfgFeature.d.ts +199 -199
- package/dist/productConfiguration/CfgFeature.js +691 -691
- package/dist/productConfiguration/CfgOption.d.ts +160 -160
- package/dist/productConfiguration/CfgOption.js +464 -464
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +136 -129
- package/dist/productConfiguration/CfgProductConfiguration.js +355 -346
- package/dist/productConfiguration/filters.d.ts +17 -17
- package/dist/productConfiguration/filters.js +141 -141
- package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
- package/dist/productConfiguration/productParamsGenerator.js +65 -65
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
- package/dist/productConfiguration/utilitiesProductConfiguration.js +89 -87
- package/dist/productLoader.d.ts +33 -33
- package/dist/productLoader.js +49 -49
- package/dist/syncGroups/SyncGroupsApplyMode.d.ts +20 -20
- package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
- package/dist/syncGroups/SyncGroupsHandler.d.ts +47 -47
- package/dist/syncGroups/SyncGroupsHandler.js +370 -370
- package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
- package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
- package/dist/syncGroups/SyncGroupsState.d.ts +39 -39
- package/dist/syncGroups/SyncGroupsState.js +167 -167
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
- package/dist/syncGroups/SyncGroupsTransaction.js +589 -589
- package/dist/tasks/TaskHandler.d.ts +77 -77
- package/dist/tasks/TaskHandler.js +276 -276
- package/dist/tasks/formats.d.ts +4 -4
- package/dist/tasks/formats.js +7 -7
- package/dist/tests/testData/collectorForTest.d.ts +73 -73
- package/dist/tests/testData/collectorForTest.js +194 -194
- package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
- package/dist/tests/testData/dummyProductForTest.js +32 -32
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +282 -282
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +187 -187
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +185 -185
- package/dist/tests/testData/testDataConstraints.d.ts +3 -3
- package/dist/tests/testData/testDataConstraints.js +174 -174
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
- package/dist/tests/testData/testDataOptions.d.ts +12 -12
- package/dist/tests/testData/testDataOptions.js +60 -60
- package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
- package/dist/tests/testData/testDataProductAggregatedPrice.js +189 -189
- package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
- package/dist/tests/testData/testDataUpcharge.js +121 -121
- package/dist/utilitiesCatalogueData.d.ts +47 -47
- package/dist/utilitiesCatalogueData.js +180 -180
- package/dist/utilitiesCataloguePermission.d.ts +38 -38
- package/dist/utilitiesCataloguePermission.js +79 -79
- package/dist/utilitiesConfiguration.d.ts +28 -28
- package/dist/utilitiesConfiguration.js +200 -200
- package/dist/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +114 -114
- package/package.json +3 -3
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { _CfgProductInternal } from "../CfgProduct.js";
|
|
2
|
-
import { _CfgFeatureInternal } from "../productConfiguration/CfgFeature.js";
|
|
3
|
-
import { _CfgOptionInternal } from "../productConfiguration/CfgOption.js";
|
|
4
|
-
import { _CfgProductConfigurationInternal } from "../productConfiguration/CfgProductConfiguration.js";
|
|
5
|
-
export declare type CfgPathSegment = string;
|
|
6
|
-
/**
|
|
7
|
-
* Represents the path to a node in the configuration tree.
|
|
8
|
-
*
|
|
9
|
-
* The format consists of a number of CfgPathSegments, each of which is currently a string. The
|
|
10
|
-
* exact meaning of the strings vary depending on where they are located in the path.
|
|
11
|
-
*
|
|
12
|
-
* @warning
|
|
13
|
-
* The format is strictly internal and can change in later versions of the SDK.
|
|
14
|
-
* Data stored in a CfgPath should be thus be considered transient and never stored or transmitted.
|
|
15
|
-
*/
|
|
16
|
-
export declare type CfgPath = CfgPathSegment[];
|
|
17
|
-
declare type PathItemType = _CfgProductInternal | _CfgProductConfigurationInternal | _CfgFeatureInternal | _CfgOptionInternal;
|
|
18
|
-
export declare class SyncGroupsPathHelper {
|
|
19
|
-
static getPath(item: PathItemType): CfgPath;
|
|
20
|
-
static getFromPath(path: CfgPath, root: PathItemType): PathItemType;
|
|
21
|
-
static getProductFromPath(path: CfgPath, item: _CfgProductInternal): _CfgProductInternal;
|
|
22
|
-
static getProductConfigurationFromPath(path: CfgPath, item: _CfgProductInternal): _CfgProductConfigurationInternal;
|
|
23
|
-
static getFeatureFromPath(path: CfgPath, item: PathItemType): _CfgFeatureInternal;
|
|
24
|
-
static getOptionFromPath(path: CfgPath, item: PathItemType): _CfgOptionInternal;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
1
|
+
import { _CfgProductInternal } from "../CfgProduct.js";
|
|
2
|
+
import { _CfgFeatureInternal } from "../productConfiguration/CfgFeature.js";
|
|
3
|
+
import { _CfgOptionInternal } from "../productConfiguration/CfgOption.js";
|
|
4
|
+
import { _CfgProductConfigurationInternal } from "../productConfiguration/CfgProductConfiguration.js";
|
|
5
|
+
export declare type CfgPathSegment = string;
|
|
6
|
+
/**
|
|
7
|
+
* Represents the path to a node in the configuration tree.
|
|
8
|
+
*
|
|
9
|
+
* The format consists of a number of CfgPathSegments, each of which is currently a string. The
|
|
10
|
+
* exact meaning of the strings vary depending on where they are located in the path.
|
|
11
|
+
*
|
|
12
|
+
* @warning
|
|
13
|
+
* The format is strictly internal and can change in later versions of the SDK.
|
|
14
|
+
* Data stored in a CfgPath should be thus be considered transient and never stored or transmitted.
|
|
15
|
+
*/
|
|
16
|
+
export declare type CfgPath = CfgPathSegment[];
|
|
17
|
+
declare type PathItemType = _CfgProductInternal | _CfgProductConfigurationInternal | _CfgFeatureInternal | _CfgOptionInternal;
|
|
18
|
+
export declare class SyncGroupsPathHelper {
|
|
19
|
+
static getPath(item: PathItemType): CfgPath;
|
|
20
|
+
static getFromPath(path: CfgPath, root: PathItemType): PathItemType;
|
|
21
|
+
static getProductFromPath(path: CfgPath, item: _CfgProductInternal): _CfgProductInternal;
|
|
22
|
+
static getProductConfigurationFromPath(path: CfgPath, item: _CfgProductInternal): _CfgProductConfigurationInternal;
|
|
23
|
+
static getFeatureFromPath(path: CfgPath, item: PathItemType): _CfgFeatureInternal;
|
|
24
|
+
static getOptionFromPath(path: CfgPath, item: PathItemType): _CfgOptionInternal;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
27
27
|
//# sourceMappingURL=SyncGroupsPathHelper.d.ts.map
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import { assert, assertDefined } from "@configura/web-utilities";
|
|
2
|
-
import { _CfgProductInternal } from "../CfgProduct.js";
|
|
3
|
-
import { _CfgFeatureInternal } from "../productConfiguration/CfgFeature.js";
|
|
4
|
-
import { _CfgOptionInternal } from "../productConfiguration/CfgOption.js";
|
|
5
|
-
import { _CfgProductConfigurationInternal } from "../productConfiguration/CfgProductConfiguration.js";
|
|
6
|
-
export class SyncGroupsPathHelper {
|
|
7
|
-
static getPath(item) {
|
|
8
|
-
if (item instanceof _CfgProductInternal) {
|
|
9
|
-
const parent = item.parent;
|
|
10
|
-
const refKey = item.refKey;
|
|
11
|
-
if (parent === undefined || refKey === undefined) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
return [...this.getPath(parent), "p", refKey];
|
|
15
|
-
}
|
|
16
|
-
if (item instanceof _CfgProductConfigurationInternal) {
|
|
17
|
-
return [...this.getPath(item.parentProduct), "c"];
|
|
18
|
-
}
|
|
19
|
-
if (item instanceof _CfgFeatureInternal) {
|
|
20
|
-
return [...this.getPath(item.parent), item.code];
|
|
21
|
-
}
|
|
22
|
-
if (item instanceof _CfgOptionInternal) {
|
|
23
|
-
return [...this.getPath(item.parent), item.code];
|
|
24
|
-
}
|
|
25
|
-
throw new Error("This should not happen");
|
|
26
|
-
}
|
|
27
|
-
static getFromPath(path, root) {
|
|
28
|
-
path = path.slice();
|
|
29
|
-
let item = root;
|
|
30
|
-
while (path.length > 0) {
|
|
31
|
-
const segment = path.shift();
|
|
32
|
-
if (item instanceof _CfgProductInternal) {
|
|
33
|
-
switch (segment) {
|
|
34
|
-
case "p": {
|
|
35
|
-
const refKey = path.shift();
|
|
36
|
-
const additional = item.additionalProducts.find((p) => p.refKey === refKey);
|
|
37
|
-
assertDefined(additional, `Additional product not found "p, ${refKey !== null && refKey !== void 0 ? refKey : ""}, ${path.join(", ")}"`);
|
|
38
|
-
item = additional._internal;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
case "c":
|
|
42
|
-
assert(item instanceof _CfgProductInternal, "Was not product");
|
|
43
|
-
item = item.configuration._internal;
|
|
44
|
-
break;
|
|
45
|
-
default:
|
|
46
|
-
throw new Error(`Unexpected path segment "${segment !== null && segment !== void 0 ? segment : ""}"`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else if (item instanceof _CfgProductConfigurationInternal) {
|
|
50
|
-
const feature = item.features.find((f) => f.code === segment);
|
|
51
|
-
assertDefined(feature, `Feature not found "${segment !== null && segment !== void 0 ? segment : ""}", ${path.join(", ")}`);
|
|
52
|
-
item = feature._internal;
|
|
53
|
-
}
|
|
54
|
-
else if (item instanceof _CfgFeatureInternal) {
|
|
55
|
-
const option = item.options.find((o) => o.code === segment);
|
|
56
|
-
assertDefined(option, `Option not found "${segment !== null && segment !== void 0 ? segment : ""}", ${path.join(", ")}`);
|
|
57
|
-
item = option._internal;
|
|
58
|
-
}
|
|
59
|
-
else if (item instanceof _CfgOptionInternal) {
|
|
60
|
-
const feature = item.features.find((o) => o.code === segment);
|
|
61
|
-
assertDefined(feature, `Feature not found "${segment !== null && segment !== void 0 ? segment : ""}", ${path.join(", ")}`);
|
|
62
|
-
item = feature._internal;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
throw new Error("This should not happen (unexpected type)");
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return item;
|
|
69
|
-
}
|
|
70
|
-
static getProductFromPath(path, item) {
|
|
71
|
-
const p = this.getFromPath(path, item);
|
|
72
|
-
assert(p instanceof _CfgProductInternal, `Path did not lead to a Product`);
|
|
73
|
-
return p;
|
|
74
|
-
}
|
|
75
|
-
static getProductConfigurationFromPath(path, item) {
|
|
76
|
-
const c = this.getFromPath(path, item);
|
|
77
|
-
assert(c instanceof _CfgProductConfigurationInternal, `Path did not lead to a ProductConfiguration"`);
|
|
78
|
-
return c;
|
|
79
|
-
}
|
|
80
|
-
static getFeatureFromPath(path, item) {
|
|
81
|
-
const f = this.getFromPath(path, item);
|
|
82
|
-
assert(f instanceof _CfgFeatureInternal, `Path did not lead to a Feature`);
|
|
83
|
-
return f;
|
|
84
|
-
}
|
|
85
|
-
static getOptionFromPath(path, item) {
|
|
86
|
-
const o = this.getFromPath(path, item);
|
|
87
|
-
assert(o instanceof _CfgOptionInternal, `Path did not lead to a Option`);
|
|
88
|
-
return o;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
import { assert, assertDefined } from "@configura/web-utilities";
|
|
2
|
+
import { _CfgProductInternal } from "../CfgProduct.js";
|
|
3
|
+
import { _CfgFeatureInternal } from "../productConfiguration/CfgFeature.js";
|
|
4
|
+
import { _CfgOptionInternal } from "../productConfiguration/CfgOption.js";
|
|
5
|
+
import { _CfgProductConfigurationInternal } from "../productConfiguration/CfgProductConfiguration.js";
|
|
6
|
+
export class SyncGroupsPathHelper {
|
|
7
|
+
static getPath(item) {
|
|
8
|
+
if (item instanceof _CfgProductInternal) {
|
|
9
|
+
const parent = item.parent;
|
|
10
|
+
const refKey = item.refKey;
|
|
11
|
+
if (parent === undefined || refKey === undefined) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return [...this.getPath(parent), "p", refKey];
|
|
15
|
+
}
|
|
16
|
+
if (item instanceof _CfgProductConfigurationInternal) {
|
|
17
|
+
return [...this.getPath(item.parentProduct), "c"];
|
|
18
|
+
}
|
|
19
|
+
if (item instanceof _CfgFeatureInternal) {
|
|
20
|
+
return [...this.getPath(item.parent), item.code];
|
|
21
|
+
}
|
|
22
|
+
if (item instanceof _CfgOptionInternal) {
|
|
23
|
+
return [...this.getPath(item.parent), item.code];
|
|
24
|
+
}
|
|
25
|
+
throw new Error("This should not happen");
|
|
26
|
+
}
|
|
27
|
+
static getFromPath(path, root) {
|
|
28
|
+
path = path.slice();
|
|
29
|
+
let item = root;
|
|
30
|
+
while (path.length > 0) {
|
|
31
|
+
const segment = path.shift();
|
|
32
|
+
if (item instanceof _CfgProductInternal) {
|
|
33
|
+
switch (segment) {
|
|
34
|
+
case "p": {
|
|
35
|
+
const refKey = path.shift();
|
|
36
|
+
const additional = item.additionalProducts.find((p) => p.refKey === refKey);
|
|
37
|
+
assertDefined(additional, `Additional product not found "p, ${refKey !== null && refKey !== void 0 ? refKey : ""}, ${path.join(", ")}"`);
|
|
38
|
+
item = additional._internal;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case "c":
|
|
42
|
+
assert(item instanceof _CfgProductInternal, "Was not product");
|
|
43
|
+
item = item.configuration._internal;
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Unexpected path segment "${segment !== null && segment !== void 0 ? segment : ""}"`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (item instanceof _CfgProductConfigurationInternal) {
|
|
50
|
+
const feature = item.features.find((f) => f.code === segment);
|
|
51
|
+
assertDefined(feature, `Feature not found "${segment !== null && segment !== void 0 ? segment : ""}", ${path.join(", ")}`);
|
|
52
|
+
item = feature._internal;
|
|
53
|
+
}
|
|
54
|
+
else if (item instanceof _CfgFeatureInternal) {
|
|
55
|
+
const option = item.options.find((o) => o.code === segment);
|
|
56
|
+
assertDefined(option, `Option not found "${segment !== null && segment !== void 0 ? segment : ""}", ${path.join(", ")}`);
|
|
57
|
+
item = option._internal;
|
|
58
|
+
}
|
|
59
|
+
else if (item instanceof _CfgOptionInternal) {
|
|
60
|
+
const feature = item.features.find((o) => o.code === segment);
|
|
61
|
+
assertDefined(feature, `Feature not found "${segment !== null && segment !== void 0 ? segment : ""}", ${path.join(", ")}`);
|
|
62
|
+
item = feature._internal;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw new Error("This should not happen (unexpected type)");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return item;
|
|
69
|
+
}
|
|
70
|
+
static getProductFromPath(path, item) {
|
|
71
|
+
const p = this.getFromPath(path, item);
|
|
72
|
+
assert(p instanceof _CfgProductInternal, `Path did not lead to a Product`);
|
|
73
|
+
return p;
|
|
74
|
+
}
|
|
75
|
+
static getProductConfigurationFromPath(path, item) {
|
|
76
|
+
const c = this.getFromPath(path, item);
|
|
77
|
+
assert(c instanceof _CfgProductConfigurationInternal, `Path did not lead to a ProductConfiguration"`);
|
|
78
|
+
return c;
|
|
79
|
+
}
|
|
80
|
+
static getFeatureFromPath(path, item) {
|
|
81
|
+
const f = this.getFromPath(path, item);
|
|
82
|
+
assert(f instanceof _CfgFeatureInternal, `Path did not lead to a Feature`);
|
|
83
|
+
return f;
|
|
84
|
+
}
|
|
85
|
+
static getOptionFromPath(path, item) {
|
|
86
|
+
const o = this.getFromPath(path, item);
|
|
87
|
+
assert(o instanceof _CfgOptionInternal, `Path did not lead to a Option`);
|
|
88
|
+
return o;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { DtoSyncGroupState } from "../CatalogueAPI.js";
|
|
2
|
-
import { OptionCode, SyncCode } from "./SyncGroupsHandler.js";
|
|
3
|
-
/**
|
|
4
|
-
* The SyncState is used to keep track of the current value of the SyncGroups.
|
|
5
|
-
*
|
|
6
|
-
* SelectOne and SelectMany uses fully separate states internally since the two types of features
|
|
7
|
-
* are synced separately. See SyncGroupsHandler for details.
|
|
8
|
-
*/
|
|
9
|
-
export declare class SyncGroupsState {
|
|
10
|
-
private _verboseLogging;
|
|
11
|
-
readonly _selectOne: Map<SyncCode, OptionCode>;
|
|
12
|
-
readonly _selectMany: Map<SyncCode, Map<OptionCode, boolean>>;
|
|
13
|
-
/**
|
|
14
|
-
* @param verboseLogging Set to true to get verbose sync state changes logged to the console.
|
|
15
|
-
*/
|
|
16
|
-
constructor(_verboseLogging: boolean, initial: DtoSyncGroupState | undefined);
|
|
17
|
-
get verboseLogging(): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Set to true to get verbose sync state changes logged to the console.
|
|
20
|
-
*/
|
|
21
|
-
set verboseLogging(v: boolean);
|
|
22
|
-
/**
|
|
23
|
-
* @returns a deep copy of the SyncGroupState.
|
|
24
|
-
*/
|
|
25
|
-
clone(): SyncGroupsState;
|
|
26
|
-
/**
|
|
27
|
-
* Replaces the internal state of this SyncGroupState with a deep copy of the one in source.
|
|
28
|
-
* @returns the updated SyncGroupState.
|
|
29
|
-
*/
|
|
30
|
-
copyFrom(source: SyncGroupsState): SyncGroupsState;
|
|
31
|
-
setForSelectOne(syncCode: SyncCode, optionCode: OptionCode): void;
|
|
32
|
-
setForSelectMany(syncCode: SyncCode, optionCode: OptionCode, selected: boolean): void;
|
|
33
|
-
getForSelectOne(syncCode: SyncCode): OptionCode | undefined;
|
|
34
|
-
getForSelectMany(syncCode: SyncCode, optionCode: OptionCode): boolean | undefined;
|
|
35
|
-
/** Overrides the current sync state */
|
|
36
|
-
setCompact(s: DtoSyncGroupState): void;
|
|
37
|
-
getCompact(): DtoSyncGroupState;
|
|
38
|
-
log(syncCode?: SyncCode, optionCode?: OptionCode, selected?: boolean): void;
|
|
39
|
-
}
|
|
1
|
+
import { DtoSyncGroupState } from "../CatalogueAPI.js";
|
|
2
|
+
import { OptionCode, SyncCode } from "./SyncGroupsHandler.js";
|
|
3
|
+
/**
|
|
4
|
+
* The SyncState is used to keep track of the current value of the SyncGroups.
|
|
5
|
+
*
|
|
6
|
+
* SelectOne and SelectMany uses fully separate states internally since the two types of features
|
|
7
|
+
* are synced separately. See SyncGroupsHandler for details.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SyncGroupsState {
|
|
10
|
+
private _verboseLogging;
|
|
11
|
+
readonly _selectOne: Map<SyncCode, OptionCode>;
|
|
12
|
+
readonly _selectMany: Map<SyncCode, Map<OptionCode, boolean>>;
|
|
13
|
+
/**
|
|
14
|
+
* @param verboseLogging Set to true to get verbose sync state changes logged to the console.
|
|
15
|
+
*/
|
|
16
|
+
constructor(_verboseLogging: boolean, initial: DtoSyncGroupState | undefined);
|
|
17
|
+
get verboseLogging(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Set to true to get verbose sync state changes logged to the console.
|
|
20
|
+
*/
|
|
21
|
+
set verboseLogging(v: boolean);
|
|
22
|
+
/**
|
|
23
|
+
* @returns a deep copy of the SyncGroupState.
|
|
24
|
+
*/
|
|
25
|
+
clone(): SyncGroupsState;
|
|
26
|
+
/**
|
|
27
|
+
* Replaces the internal state of this SyncGroupState with a deep copy of the one in source.
|
|
28
|
+
* @returns the updated SyncGroupState.
|
|
29
|
+
*/
|
|
30
|
+
copyFrom(source: SyncGroupsState): SyncGroupsState;
|
|
31
|
+
setForSelectOne(syncCode: SyncCode, optionCode: OptionCode): void;
|
|
32
|
+
setForSelectMany(syncCode: SyncCode, optionCode: OptionCode, selected: boolean): void;
|
|
33
|
+
getForSelectOne(syncCode: SyncCode): OptionCode | undefined;
|
|
34
|
+
getForSelectMany(syncCode: SyncCode, optionCode: OptionCode): boolean | undefined;
|
|
35
|
+
/** Overrides the current sync state */
|
|
36
|
+
setCompact(s: DtoSyncGroupState): void;
|
|
37
|
+
getCompact(): DtoSyncGroupState;
|
|
38
|
+
log(syncCode?: SyncCode, optionCode?: OptionCode, selected?: boolean): void;
|
|
39
|
+
}
|
|
40
40
|
//# sourceMappingURL=SyncGroupsState.d.ts.map
|
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The SyncState is used to keep track of the current value of the SyncGroups.
|
|
3
|
-
*
|
|
4
|
-
* SelectOne and SelectMany uses fully separate states internally since the two types of features
|
|
5
|
-
* are synced separately. See SyncGroupsHandler for details.
|
|
6
|
-
*/
|
|
7
|
-
export class SyncGroupsState {
|
|
8
|
-
/**
|
|
9
|
-
* @param verboseLogging Set to true to get verbose sync state changes logged to the console.
|
|
10
|
-
*/
|
|
11
|
-
constructor(_verboseLogging, initial) {
|
|
12
|
-
this._verboseLogging = _verboseLogging;
|
|
13
|
-
this._selectOne = new Map();
|
|
14
|
-
this._selectMany = new Map();
|
|
15
|
-
this.setCompact(initial !== null && initial !== void 0 ? initial : {});
|
|
16
|
-
}
|
|
17
|
-
get verboseLogging() {
|
|
18
|
-
return this._verboseLogging;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Set to true to get verbose sync state changes logged to the console.
|
|
22
|
-
*/
|
|
23
|
-
set verboseLogging(v) {
|
|
24
|
-
this._verboseLogging = v;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @returns a deep copy of the SyncGroupState.
|
|
28
|
-
*/
|
|
29
|
-
clone() {
|
|
30
|
-
return new SyncGroupsState(this._verboseLogging, this.getCompact());
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Replaces the internal state of this SyncGroupState with a deep copy of the one in source.
|
|
34
|
-
* @returns the updated SyncGroupState.
|
|
35
|
-
*/
|
|
36
|
-
copyFrom(source) {
|
|
37
|
-
this._selectOne.clear();
|
|
38
|
-
this._selectMany.clear();
|
|
39
|
-
// The Exclude part below ensures that OptionCode is a defined as a primitive.
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
41
|
-
let entryOne;
|
|
42
|
-
for (entryOne of source._selectOne) {
|
|
43
|
-
this._selectOne.set(...entryOne);
|
|
44
|
-
}
|
|
45
|
-
let entryMany;
|
|
46
|
-
for (entryMany of source._selectMany) {
|
|
47
|
-
this._selectMany.set(entryMany[0], new Map(entryMany[1]));
|
|
48
|
-
}
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
setForSelectOne(syncCode, optionCode) {
|
|
52
|
-
this._selectOne.set(syncCode, optionCode);
|
|
53
|
-
this.log(syncCode, optionCode);
|
|
54
|
-
}
|
|
55
|
-
setForSelectMany(syncCode, optionCode, selected) {
|
|
56
|
-
let entry = this._selectMany.get(syncCode);
|
|
57
|
-
if (entry === undefined) {
|
|
58
|
-
entry = new Map();
|
|
59
|
-
this._selectMany.set(syncCode, entry);
|
|
60
|
-
}
|
|
61
|
-
entry.set(optionCode, selected);
|
|
62
|
-
this.log(syncCode, optionCode, selected);
|
|
63
|
-
}
|
|
64
|
-
getForSelectOne(syncCode) {
|
|
65
|
-
return this._selectOne.get(syncCode);
|
|
66
|
-
}
|
|
67
|
-
getForSelectMany(syncCode, optionCode) {
|
|
68
|
-
var _a;
|
|
69
|
-
return (_a = this._selectMany.get(syncCode)) === null || _a === void 0 ? void 0 : _a.get(optionCode);
|
|
70
|
-
}
|
|
71
|
-
/** Overrides the current sync state */
|
|
72
|
-
setCompact(s) {
|
|
73
|
-
this._selectOne.clear();
|
|
74
|
-
this._selectMany.clear();
|
|
75
|
-
const { selectOne, selectMany } = s;
|
|
76
|
-
if (selectOne !== undefined) {
|
|
77
|
-
for (const { syncCode, optionCode } of selectOne) {
|
|
78
|
-
this._selectOne.set(syncCode, optionCode);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (selectMany !== undefined) {
|
|
82
|
-
for (const { syncCode, optionCode, selected } of selectMany) {
|
|
83
|
-
let entry = this._selectMany.get(syncCode);
|
|
84
|
-
if (entry === undefined) {
|
|
85
|
-
entry = new Map();
|
|
86
|
-
this._selectMany.set(syncCode, entry);
|
|
87
|
-
}
|
|
88
|
-
entry.set(optionCode, selected);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
getCompact() {
|
|
93
|
-
const result = {};
|
|
94
|
-
if (this._selectOne.size !== 0) {
|
|
95
|
-
const resultSelectOne = [];
|
|
96
|
-
for (const [syncCode, optionCode] of this._selectOne) {
|
|
97
|
-
resultSelectOne.push({ syncCode, optionCode });
|
|
98
|
-
}
|
|
99
|
-
result.selectOne = resultSelectOne;
|
|
100
|
-
}
|
|
101
|
-
if (this._selectMany.size !== 0) {
|
|
102
|
-
const resultSelectMany = [];
|
|
103
|
-
for (const [syncCode, optionCodeToSelected] of this._selectMany) {
|
|
104
|
-
for (const [optionCode, selected] of optionCodeToSelected) {
|
|
105
|
-
resultSelectMany.push({ syncCode, optionCode, selected });
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
result.selectMany = resultSelectMany;
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
}
|
|
112
|
-
log(syncCode, optionCode, selected) {
|
|
113
|
-
if (!this._verboseLogging) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const isMany = selected !== undefined;
|
|
117
|
-
const selectOne = Array.from(this._selectOne.entries());
|
|
118
|
-
const selectMany = Array.from(this._selectMany.entries()).reduce((a, [groupCode, optionCodeToSelected]) => {
|
|
119
|
-
for (const [optionCode, selected] of optionCodeToSelected) {
|
|
120
|
-
a.push([groupCode, optionCode, selected]);
|
|
121
|
-
}
|
|
122
|
-
return a;
|
|
123
|
-
}, []);
|
|
124
|
-
let columnWidth = 1;
|
|
125
|
-
selectOne.forEach((e) => {
|
|
126
|
-
columnWidth = Math.max(columnWidth, e[0].length);
|
|
127
|
-
});
|
|
128
|
-
selectMany.forEach((e) => {
|
|
129
|
-
columnWidth = Math.max(columnWidth, e[0].length);
|
|
130
|
-
});
|
|
131
|
-
const padding = Array(columnWidth).join(" ");
|
|
132
|
-
const bold = "font-weight: bold";
|
|
133
|
-
const styles = [];
|
|
134
|
-
let msg = "";
|
|
135
|
-
if (syncCode !== undefined && isMany) {
|
|
136
|
-
msg += `%c${optionCode !== null && optionCode !== void 0 ? optionCode : ""}%c in %c${syncCode}%c set to %c${selected ? "on" : "off"}`;
|
|
137
|
-
styles.push(bold, "", bold, "", bold);
|
|
138
|
-
}
|
|
139
|
-
else if (syncCode !== undefined && !isMany) {
|
|
140
|
-
msg += `%c${syncCode}%c set to %c${optionCode !== null && optionCode !== void 0 ? optionCode : ""}`;
|
|
141
|
-
styles.push(bold, "", bold);
|
|
142
|
-
}
|
|
143
|
-
msg += "\n\n%cSync State (single)";
|
|
144
|
-
styles.push(bold);
|
|
145
|
-
selectOne.forEach((e) => {
|
|
146
|
-
const match = !isMany && syncCode === e[0];
|
|
147
|
-
msg += `\n%c${match ? "*" : " "} ${(padding + e[0]).slice(-columnWidth)}: ${e[1]}`;
|
|
148
|
-
styles.push(match ? bold : "");
|
|
149
|
-
});
|
|
150
|
-
if (selectOne.length === 0) {
|
|
151
|
-
msg += "\n%c <Empty>";
|
|
152
|
-
styles.push("");
|
|
153
|
-
}
|
|
154
|
-
msg += "\n\n%cSync State (multi)";
|
|
155
|
-
styles.push(bold);
|
|
156
|
-
selectMany.forEach((e) => {
|
|
157
|
-
const match = isMany && syncCode === e[0] && optionCode === e[1];
|
|
158
|
-
msg += `\n%c${match ? "*" : " "} ${(padding + e[0]).slice(-columnWidth)}: ${e[2] === true ? "\u2705" : "\u274c"} ${e[1]}`;
|
|
159
|
-
styles.push(match ? bold : "");
|
|
160
|
-
});
|
|
161
|
-
if (selectMany.length === 0) {
|
|
162
|
-
msg += "\n%c <Empty>";
|
|
163
|
-
styles.push("");
|
|
164
|
-
}
|
|
165
|
-
console.log(msg, ...styles);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The SyncState is used to keep track of the current value of the SyncGroups.
|
|
3
|
+
*
|
|
4
|
+
* SelectOne and SelectMany uses fully separate states internally since the two types of features
|
|
5
|
+
* are synced separately. See SyncGroupsHandler for details.
|
|
6
|
+
*/
|
|
7
|
+
export class SyncGroupsState {
|
|
8
|
+
/**
|
|
9
|
+
* @param verboseLogging Set to true to get verbose sync state changes logged to the console.
|
|
10
|
+
*/
|
|
11
|
+
constructor(_verboseLogging, initial) {
|
|
12
|
+
this._verboseLogging = _verboseLogging;
|
|
13
|
+
this._selectOne = new Map();
|
|
14
|
+
this._selectMany = new Map();
|
|
15
|
+
this.setCompact(initial !== null && initial !== void 0 ? initial : {});
|
|
16
|
+
}
|
|
17
|
+
get verboseLogging() {
|
|
18
|
+
return this._verboseLogging;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set to true to get verbose sync state changes logged to the console.
|
|
22
|
+
*/
|
|
23
|
+
set verboseLogging(v) {
|
|
24
|
+
this._verboseLogging = v;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @returns a deep copy of the SyncGroupState.
|
|
28
|
+
*/
|
|
29
|
+
clone() {
|
|
30
|
+
return new SyncGroupsState(this._verboseLogging, this.getCompact());
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Replaces the internal state of this SyncGroupState with a deep copy of the one in source.
|
|
34
|
+
* @returns the updated SyncGroupState.
|
|
35
|
+
*/
|
|
36
|
+
copyFrom(source) {
|
|
37
|
+
this._selectOne.clear();
|
|
38
|
+
this._selectMany.clear();
|
|
39
|
+
// The Exclude part below ensures that OptionCode is a defined as a primitive.
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
41
|
+
let entryOne;
|
|
42
|
+
for (entryOne of source._selectOne) {
|
|
43
|
+
this._selectOne.set(...entryOne);
|
|
44
|
+
}
|
|
45
|
+
let entryMany;
|
|
46
|
+
for (entryMany of source._selectMany) {
|
|
47
|
+
this._selectMany.set(entryMany[0], new Map(entryMany[1]));
|
|
48
|
+
}
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
setForSelectOne(syncCode, optionCode) {
|
|
52
|
+
this._selectOne.set(syncCode, optionCode);
|
|
53
|
+
this.log(syncCode, optionCode);
|
|
54
|
+
}
|
|
55
|
+
setForSelectMany(syncCode, optionCode, selected) {
|
|
56
|
+
let entry = this._selectMany.get(syncCode);
|
|
57
|
+
if (entry === undefined) {
|
|
58
|
+
entry = new Map();
|
|
59
|
+
this._selectMany.set(syncCode, entry);
|
|
60
|
+
}
|
|
61
|
+
entry.set(optionCode, selected);
|
|
62
|
+
this.log(syncCode, optionCode, selected);
|
|
63
|
+
}
|
|
64
|
+
getForSelectOne(syncCode) {
|
|
65
|
+
return this._selectOne.get(syncCode);
|
|
66
|
+
}
|
|
67
|
+
getForSelectMany(syncCode, optionCode) {
|
|
68
|
+
var _a;
|
|
69
|
+
return (_a = this._selectMany.get(syncCode)) === null || _a === void 0 ? void 0 : _a.get(optionCode);
|
|
70
|
+
}
|
|
71
|
+
/** Overrides the current sync state */
|
|
72
|
+
setCompact(s) {
|
|
73
|
+
this._selectOne.clear();
|
|
74
|
+
this._selectMany.clear();
|
|
75
|
+
const { selectOne, selectMany } = s;
|
|
76
|
+
if (selectOne !== undefined) {
|
|
77
|
+
for (const { syncCode, optionCode } of selectOne) {
|
|
78
|
+
this._selectOne.set(syncCode, optionCode);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (selectMany !== undefined) {
|
|
82
|
+
for (const { syncCode, optionCode, selected } of selectMany) {
|
|
83
|
+
let entry = this._selectMany.get(syncCode);
|
|
84
|
+
if (entry === undefined) {
|
|
85
|
+
entry = new Map();
|
|
86
|
+
this._selectMany.set(syncCode, entry);
|
|
87
|
+
}
|
|
88
|
+
entry.set(optionCode, selected);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
getCompact() {
|
|
93
|
+
const result = {};
|
|
94
|
+
if (this._selectOne.size !== 0) {
|
|
95
|
+
const resultSelectOne = [];
|
|
96
|
+
for (const [syncCode, optionCode] of this._selectOne) {
|
|
97
|
+
resultSelectOne.push({ syncCode, optionCode });
|
|
98
|
+
}
|
|
99
|
+
result.selectOne = resultSelectOne;
|
|
100
|
+
}
|
|
101
|
+
if (this._selectMany.size !== 0) {
|
|
102
|
+
const resultSelectMany = [];
|
|
103
|
+
for (const [syncCode, optionCodeToSelected] of this._selectMany) {
|
|
104
|
+
for (const [optionCode, selected] of optionCodeToSelected) {
|
|
105
|
+
resultSelectMany.push({ syncCode, optionCode, selected });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
result.selectMany = resultSelectMany;
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
log(syncCode, optionCode, selected) {
|
|
113
|
+
if (!this._verboseLogging) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const isMany = selected !== undefined;
|
|
117
|
+
const selectOne = Array.from(this._selectOne.entries());
|
|
118
|
+
const selectMany = Array.from(this._selectMany.entries()).reduce((a, [groupCode, optionCodeToSelected]) => {
|
|
119
|
+
for (const [optionCode, selected] of optionCodeToSelected) {
|
|
120
|
+
a.push([groupCode, optionCode, selected]);
|
|
121
|
+
}
|
|
122
|
+
return a;
|
|
123
|
+
}, []);
|
|
124
|
+
let columnWidth = 1;
|
|
125
|
+
selectOne.forEach((e) => {
|
|
126
|
+
columnWidth = Math.max(columnWidth, e[0].length);
|
|
127
|
+
});
|
|
128
|
+
selectMany.forEach((e) => {
|
|
129
|
+
columnWidth = Math.max(columnWidth, e[0].length);
|
|
130
|
+
});
|
|
131
|
+
const padding = Array(columnWidth).join(" ");
|
|
132
|
+
const bold = "font-weight: bold";
|
|
133
|
+
const styles = [];
|
|
134
|
+
let msg = "";
|
|
135
|
+
if (syncCode !== undefined && isMany) {
|
|
136
|
+
msg += `%c${optionCode !== null && optionCode !== void 0 ? optionCode : ""}%c in %c${syncCode}%c set to %c${selected ? "on" : "off"}`;
|
|
137
|
+
styles.push(bold, "", bold, "", bold);
|
|
138
|
+
}
|
|
139
|
+
else if (syncCode !== undefined && !isMany) {
|
|
140
|
+
msg += `%c${syncCode}%c set to %c${optionCode !== null && optionCode !== void 0 ? optionCode : ""}`;
|
|
141
|
+
styles.push(bold, "", bold);
|
|
142
|
+
}
|
|
143
|
+
msg += "\n\n%cSync State (single)";
|
|
144
|
+
styles.push(bold);
|
|
145
|
+
selectOne.forEach((e) => {
|
|
146
|
+
const match = !isMany && syncCode === e[0];
|
|
147
|
+
msg += `\n%c${match ? "*" : " "} ${(padding + e[0]).slice(-columnWidth)}: ${e[1]}`;
|
|
148
|
+
styles.push(match ? bold : "");
|
|
149
|
+
});
|
|
150
|
+
if (selectOne.length === 0) {
|
|
151
|
+
msg += "\n%c <Empty>";
|
|
152
|
+
styles.push("");
|
|
153
|
+
}
|
|
154
|
+
msg += "\n\n%cSync State (multi)";
|
|
155
|
+
styles.push(bold);
|
|
156
|
+
selectMany.forEach((e) => {
|
|
157
|
+
const match = isMany && syncCode === e[0] && optionCode === e[1];
|
|
158
|
+
msg += `\n%c${match ? "*" : " "} ${(padding + e[0]).slice(-columnWidth)}: ${e[2] === true ? "\u2705" : "\u274c"} ${e[1]}`;
|
|
159
|
+
styles.push(match ? bold : "");
|
|
160
|
+
});
|
|
161
|
+
if (selectMany.length === 0) {
|
|
162
|
+
msg += "\n%c <Empty>";
|
|
163
|
+
styles.push("");
|
|
164
|
+
}
|
|
165
|
+
console.log(msg, ...styles);
|
|
166
|
+
}
|
|
167
|
+
}
|