@configura/web-api 1.6.1 → 2.0.0-alpha.2
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 +18 -18
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +551 -507
- package/dist/CatalogueAPI.js +293 -280
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +268 -258
- package/dist/CfgProduct.js +778 -747
- package/dist/CfgReferencePathHelper.d.ts +14 -0
- package/dist/CfgReferencePathHelper.js +13 -0
- package/dist/ConfigurationConverter.d.ts +5 -0
- package/dist/ConfigurationConverter.js +72 -0
- package/dist/index.d.ts +23 -20
- package/dist/index.js +23 -20
- package/dist/io/CfgHistoryManager.d.ts +51 -0
- package/dist/io/CfgHistoryManager.js +82 -0
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -0
- package/dist/io/CfgHistoryToProdConfConnector.js +56 -0
- package/dist/io/CfgIOManager.d.ts +49 -0
- package/dist/io/CfgIOManager.js +115 -0
- package/dist/io/CfgIOProdConfConnector.d.ts +53 -0
- package/dist/io/CfgIOProdConfConnector.js +141 -0
- package/dist/io/CfgObservableStateManager.d.ts +22 -0
- package/dist/io/CfgObservableStateManager.js +65 -0
- package/dist/io/CfgObservableStateToProdConfConnector.d.ts +15 -0
- package/dist/io/CfgObservableStateToProdConfConnector.js +16 -0
- package/dist/io/CfgWindowEventManager.d.ts +22 -0
- package/dist/io/CfgWindowEventManager.js +38 -0
- package/dist/io/CfgWindowMessageManager.d.ts +41 -0
- package/dist/io/CfgWindowMessageManager.js +84 -0
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +17 -0
- package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -0
- package/dist/io/index.d.ts +9 -0
- package/dist/io/index.js +8 -0
- 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 +187 -188
- package/dist/productConfiguration/CfgFeature.js +645 -636
- package/dist/productConfiguration/CfgOption.d.ts +151 -150
- package/dist/productConfiguration/CfgOption.js +416 -426
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +117 -120
- package/dist/productConfiguration/CfgProductConfiguration.js +307 -309
- package/dist/productConfiguration/filters.d.ts +15 -15
- package/dist/productConfiguration/filters.js +70 -70
- package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
- package/dist/productConfiguration/productParamsGenerator.js +51 -51
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
- package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -80
- 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 +40 -40
- package/dist/syncGroups/SyncGroupsHandler.js +359 -358
- package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
- package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
- package/dist/syncGroups/SyncGroupsState.d.ts +35 -35
- package/dist/syncGroups/SyncGroupsState.js +125 -125
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
- package/dist/syncGroups/SyncGroupsTransaction.js +576 -576
- package/dist/tasks/TaskHandler.d.ts +77 -78
- package/dist/tasks/TaskHandler.js +275 -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 -36
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +277 -277
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +185 -185
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +183 -183
- 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 +187 -187
- package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
- package/dist/tests/testData/testDataUpcharge.js +119 -119
- package/dist/utilitiesCatalogueData.d.ts +42 -31
- package/dist/utilitiesCatalogueData.js +173 -162
- package/dist/utilitiesCataloguePermission.d.ts +38 -37
- package/dist/utilitiesCataloguePermission.js +79 -80
- package/dist/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +109 -109
- package/package.json +3 -3
|
@@ -1,181 +1,181 @@
|
|
|
1
|
-
import { CfgMtrlSourceBuffer, CfgMtrlSourceUrl } from "./CfgMtrlSource.js";
|
|
2
|
-
// In this file an "application" is a combination of 0..1 Material (Mtrl) and 0..m AreaTags.
|
|
3
|
-
// These can exist on Catalogue-level (Application Areas), Product-level, in the Feature-Options
|
|
4
|
-
// tree (Configuration) and for the sake of debugging, locally as debug overrides.
|
|
5
|
-
//
|
|
6
|
-
// What this file is about is reducing/aggregating/compiling this to a simple map which says that
|
|
7
|
-
// Area1 should have material Jeans etc. The code is written to match the behavior in CET.
|
|
8
|
-
//
|
|
9
|
-
// Side note: There is no connection in material application between products
|
|
10
|
-
// in a product with additional products. So there exists no methods for
|
|
11
|
-
// aggregating over multiple products at all.
|
|
12
|
-
/**
|
|
13
|
-
* When there are multiple applications on the same node we need to reduce these to what is
|
|
14
|
-
* actually applied. The cases where there multiple applications on the same node affecting the
|
|
15
|
-
* same thing are probably user errors i Catalogue Creator. However, Catalogue Creator allows the
|
|
16
|
-
* user to let them slip through, so we need to handle them the same way CET does.
|
|
17
|
-
*/
|
|
18
|
-
const reduceApplications = (applications, skipNoMtrl = false) => applications.reduce((acc, application) => {
|
|
19
|
-
const { areaTags, mtrl } = application;
|
|
20
|
-
// Applications which have a Mtrl but no AreaTags only have meaning on Option nodes. That
|
|
21
|
-
// specific case is handled separately, so here we require AreaTags to be set.
|
|
22
|
-
if (areaTags === undefined || areaTags.length === 0 || (skipNoMtrl && mtrl === undefined)) {
|
|
23
|
-
return acc;
|
|
24
|
-
}
|
|
25
|
-
const materialSource = mtrl && {
|
|
26
|
-
mtrl,
|
|
27
|
-
source: application,
|
|
28
|
-
overriddenByOption: false,
|
|
29
|
-
};
|
|
30
|
-
for (const areaTag of areaTags) {
|
|
31
|
-
// The rule here is use the first found. This is opposite to the rule when
|
|
32
|
-
// aggregating the tree, where the latest one found is applied
|
|
33
|
-
if (acc.has(areaTag)) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
acc.set(areaTag, materialSource);
|
|
37
|
-
}
|
|
38
|
-
return acc;
|
|
39
|
-
}, new Map());
|
|
40
|
-
export function aggregateAllMaterialApplications(applicationAreas, productMtrlApplications, productConfiguration, debugMtrlApplications = []) {
|
|
41
|
-
const areasToMaterials = new Map();
|
|
42
|
-
for (const [areaTag, mtrlSource] of reduceApplications(applicationAreas)) {
|
|
43
|
-
// When Mtrl is missing there is no fallback to later Applications in the
|
|
44
|
-
// same node. This is consistent with CET
|
|
45
|
-
if (mtrlSource === undefined) {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
areasToMaterials.set(areaTag, mtrlSource);
|
|
49
|
-
}
|
|
50
|
-
// On Product level there is fallback if Mtrl is missing, so we pass true
|
|
51
|
-
// to make it skip over Mtrl-less Applications
|
|
52
|
-
for (const [areaTag, mtrlSource] of reduceApplications(productMtrlApplications, true)) {
|
|
53
|
-
if (mtrlSource === undefined) {
|
|
54
|
-
throw new Error("Should not happen");
|
|
55
|
-
}
|
|
56
|
-
areasToMaterials.set(areaTag, mtrlSource);
|
|
57
|
-
}
|
|
58
|
-
// We can not pass areasToMaterials directly to aggregateForFeature. This is because
|
|
59
|
-
// an Application with AreaTags but no Mtrl is effectively a "reset". It's like saying
|
|
60
|
-
// "no material". But that reset should only work for the stuff that comes from the
|
|
61
|
-
// Configuration. So we must make sure we don't touch what we found from Application
|
|
62
|
-
// Areas and Product.
|
|
63
|
-
const configurationAreasToMaterials = new Map();
|
|
64
|
-
for (const feature of productConfiguration.features) {
|
|
65
|
-
// Later always beats deeper
|
|
66
|
-
aggregateForFeature(feature, configurationAreasToMaterials);
|
|
67
|
-
}
|
|
68
|
-
for (const [areaTag, mtrlSource] of configurationAreasToMaterials) {
|
|
69
|
-
areasToMaterials.set(areaTag, mtrlSource);
|
|
70
|
-
}
|
|
71
|
-
// Debug Applications we just let bulldozer over everything else.
|
|
72
|
-
for (const debugMtrlApplication of debugMtrlApplications) {
|
|
73
|
-
const { areaTags, mtrl } = debugMtrlApplication;
|
|
74
|
-
if (mtrl === undefined) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
for (const areaTag of areaTags || []) {
|
|
78
|
-
areasToMaterials.set(areaTag, {
|
|
79
|
-
mtrl: mtrl,
|
|
80
|
-
source: debugMtrlApplication,
|
|
81
|
-
overriddenByOption: false,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return areasToMaterials;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* For this Feature and it's descendants, compile the Applications into the passed areasToMaterials.
|
|
89
|
-
*/
|
|
90
|
-
function aggregateForFeature(feature, areasToMaterials, areasOpenForOverrideInOption = new Set()) {
|
|
91
|
-
const featureMtrlApplications = feature._internal.mtrlApplications;
|
|
92
|
-
for (const [areaTag, mtrlSource] of reduceApplications(featureMtrlApplications)) {
|
|
93
|
-
// As soon as a Feature sets an areaTag that tag is allowed to have its value
|
|
94
|
-
// overridden (or set if it didn't have a value from the start) by an option.
|
|
95
|
-
// This option has to have an Application with a Mtrl but no AreaTags.
|
|
96
|
-
// And it can only be done once - the first option found which fulfills the
|
|
97
|
-
// requirements will do the override. The option does not even need to be a
|
|
98
|
-
// descendant of the Feature. After this the value is fixed until
|
|
99
|
-
// a Feature or an Option comes along with the AreaTag set.
|
|
100
|
-
// That will then reset the process, and if it was on a Feature it opens for
|
|
101
|
-
// override again.
|
|
102
|
-
areasOpenForOverrideInOption.add(areaTag);
|
|
103
|
-
if (mtrlSource === undefined) {
|
|
104
|
-
areasToMaterials.delete(areaTag);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
areasToMaterials.set(areaTag, mtrlSource);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
for (const option of feature.selectedOptions) {
|
|
111
|
-
aggregateForOption(option, areasToMaterials, areasOpenForOverrideInOption);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function aggregateForOption(option, areasToMaterials, areasOpenForOverrideInOption) {
|
|
115
|
-
const optionMtrlApplications = option._internal.mtrlApplications;
|
|
116
|
-
// The last mtrl with no areaTag can be used for areasOpenForOverrideInOption
|
|
117
|
-
if (areasOpenForOverrideInOption.size !== 0) {
|
|
118
|
-
// Fast backwards loop
|
|
119
|
-
let i = optionMtrlApplications.length;
|
|
120
|
-
while (i--) {
|
|
121
|
-
const optionMtrlApplication = optionMtrlApplications[i];
|
|
122
|
-
const { areaTags, mtrl } = optionMtrlApplication;
|
|
123
|
-
if ((areaTags !== undefined && areaTags.length !== 0) || mtrl === undefined) {
|
|
124
|
-
// Only Applications with a Mtrl but no AreaTags can be used for overrides
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const mtrlSource = {
|
|
128
|
-
mtrl,
|
|
129
|
-
source: optionMtrlApplication,
|
|
130
|
-
overriddenByOption: true,
|
|
131
|
-
};
|
|
132
|
-
for (const areaTag of areasOpenForOverrideInOption) {
|
|
133
|
-
areasToMaterials.set(areaTag, mtrlSource);
|
|
134
|
-
}
|
|
135
|
-
areasOpenForOverrideInOption.clear();
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
// reduceApplications will filter out Applications with AreaTags. So there will
|
|
140
|
-
// be no overlap between Applications used for Override and Applications used
|
|
141
|
-
// for immediately setting.
|
|
142
|
-
for (const [areaTag, mtrlSource] of reduceApplications(optionMtrlApplications)) {
|
|
143
|
-
if (mtrlSource === undefined) {
|
|
144
|
-
// An Application on an Option with no Mtrl opens up for a future option
|
|
145
|
-
// to set the Mtrl (the overridden has to be an option with a Mtrl and no Area)
|
|
146
|
-
areasOpenForOverrideInOption.add(areaTag);
|
|
147
|
-
areasToMaterials.delete(areaTag);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
areasToMaterials.set(areaTag, mtrlSource);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
for (const feature of option.features || []) {
|
|
154
|
-
aggregateForFeature(feature, areasToMaterials, areasOpenForOverrideInOption);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
export function logMtrlSourceWithMetaDataToConsole(mtrlSourceWithMetaData) {
|
|
158
|
-
const tableData = {
|
|
159
|
-
Source: mtrlSourceWithMetaData.source.source,
|
|
160
|
-
OverriddenByOption: mtrlSourceWithMetaData.overriddenByOption ? "Yes" : "No",
|
|
161
|
-
};
|
|
162
|
-
const mtrl = mtrlSourceWithMetaData.mtrl;
|
|
163
|
-
if (mtrl instanceof CfgMtrlSourceUrl) {
|
|
164
|
-
tableData["From prop"] = mtrl.urlIsFromProperty;
|
|
165
|
-
tableData["url"] = mtrl.url;
|
|
166
|
-
}
|
|
167
|
-
if (mtrl instanceof CfgMtrlSourceBuffer) {
|
|
168
|
-
tableData["FileName"] = mtrl.fileName;
|
|
169
|
-
}
|
|
170
|
-
console.table(tableData);
|
|
171
|
-
}
|
|
172
|
-
export function logMaterialMappingToConsole(areasToMaterials) {
|
|
173
|
-
const sorted = Array.from(areasToMaterials);
|
|
174
|
-
sorted.sort((left, right) => left[0].toLocaleLowerCase().localeCompare(right[0].toLocaleLowerCase()));
|
|
175
|
-
for (const areaToMaterial of sorted) {
|
|
176
|
-
const [tag, mtrlSourceWithMetaData] = areaToMaterial;
|
|
177
|
-
console.groupCollapsed(`"${tag}"`);
|
|
178
|
-
logMtrlSourceWithMetaDataToConsole(mtrlSourceWithMetaData);
|
|
179
|
-
console.groupEnd();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
1
|
+
import { CfgMtrlSourceBuffer, CfgMtrlSourceUrl } from "./CfgMtrlSource.js";
|
|
2
|
+
// In this file an "application" is a combination of 0..1 Material (Mtrl) and 0..m AreaTags.
|
|
3
|
+
// These can exist on Catalogue-level (Application Areas), Product-level, in the Feature-Options
|
|
4
|
+
// tree (Configuration) and for the sake of debugging, locally as debug overrides.
|
|
5
|
+
//
|
|
6
|
+
// What this file is about is reducing/aggregating/compiling this to a simple map which says that
|
|
7
|
+
// Area1 should have material Jeans etc. The code is written to match the behavior in CET.
|
|
8
|
+
//
|
|
9
|
+
// Side note: There is no connection in material application between products
|
|
10
|
+
// in a product with additional products. So there exists no methods for
|
|
11
|
+
// aggregating over multiple products at all.
|
|
12
|
+
/**
|
|
13
|
+
* When there are multiple applications on the same node we need to reduce these to what is
|
|
14
|
+
* actually applied. The cases where there multiple applications on the same node affecting the
|
|
15
|
+
* same thing are probably user errors i Catalogue Creator. However, Catalogue Creator allows the
|
|
16
|
+
* user to let them slip through, so we need to handle them the same way CET does.
|
|
17
|
+
*/
|
|
18
|
+
const reduceApplications = (applications, skipNoMtrl = false) => applications.reduce((acc, application) => {
|
|
19
|
+
const { areaTags, mtrl } = application;
|
|
20
|
+
// Applications which have a Mtrl but no AreaTags only have meaning on Option nodes. That
|
|
21
|
+
// specific case is handled separately, so here we require AreaTags to be set.
|
|
22
|
+
if (areaTags === undefined || areaTags.length === 0 || (skipNoMtrl && mtrl === undefined)) {
|
|
23
|
+
return acc;
|
|
24
|
+
}
|
|
25
|
+
const materialSource = mtrl && {
|
|
26
|
+
mtrl,
|
|
27
|
+
source: application,
|
|
28
|
+
overriddenByOption: false,
|
|
29
|
+
};
|
|
30
|
+
for (const areaTag of areaTags) {
|
|
31
|
+
// The rule here is use the first found. This is opposite to the rule when
|
|
32
|
+
// aggregating the tree, where the latest one found is applied
|
|
33
|
+
if (acc.has(areaTag)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
acc.set(areaTag, materialSource);
|
|
37
|
+
}
|
|
38
|
+
return acc;
|
|
39
|
+
}, new Map());
|
|
40
|
+
export function aggregateAllMaterialApplications(applicationAreas, productMtrlApplications, productConfiguration, debugMtrlApplications = []) {
|
|
41
|
+
const areasToMaterials = new Map();
|
|
42
|
+
for (const [areaTag, mtrlSource] of reduceApplications(applicationAreas)) {
|
|
43
|
+
// When Mtrl is missing there is no fallback to later Applications in the
|
|
44
|
+
// same node. This is consistent with CET
|
|
45
|
+
if (mtrlSource === undefined) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
areasToMaterials.set(areaTag, mtrlSource);
|
|
49
|
+
}
|
|
50
|
+
// On Product level there is fallback if Mtrl is missing, so we pass true
|
|
51
|
+
// to make it skip over Mtrl-less Applications
|
|
52
|
+
for (const [areaTag, mtrlSource] of reduceApplications(productMtrlApplications, true)) {
|
|
53
|
+
if (mtrlSource === undefined) {
|
|
54
|
+
throw new Error("Should not happen");
|
|
55
|
+
}
|
|
56
|
+
areasToMaterials.set(areaTag, mtrlSource);
|
|
57
|
+
}
|
|
58
|
+
// We can not pass areasToMaterials directly to aggregateForFeature. This is because
|
|
59
|
+
// an Application with AreaTags but no Mtrl is effectively a "reset". It's like saying
|
|
60
|
+
// "no material". But that reset should only work for the stuff that comes from the
|
|
61
|
+
// Configuration. So we must make sure we don't touch what we found from Application
|
|
62
|
+
// Areas and Product.
|
|
63
|
+
const configurationAreasToMaterials = new Map();
|
|
64
|
+
for (const feature of productConfiguration.features) {
|
|
65
|
+
// Later always beats deeper
|
|
66
|
+
aggregateForFeature(feature, configurationAreasToMaterials);
|
|
67
|
+
}
|
|
68
|
+
for (const [areaTag, mtrlSource] of configurationAreasToMaterials) {
|
|
69
|
+
areasToMaterials.set(areaTag, mtrlSource);
|
|
70
|
+
}
|
|
71
|
+
// Debug Applications we just let bulldozer over everything else.
|
|
72
|
+
for (const debugMtrlApplication of debugMtrlApplications) {
|
|
73
|
+
const { areaTags, mtrl } = debugMtrlApplication;
|
|
74
|
+
if (mtrl === undefined) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
for (const areaTag of areaTags || []) {
|
|
78
|
+
areasToMaterials.set(areaTag, {
|
|
79
|
+
mtrl: mtrl,
|
|
80
|
+
source: debugMtrlApplication,
|
|
81
|
+
overriddenByOption: false,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return areasToMaterials;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* For this Feature and it's descendants, compile the Applications into the passed areasToMaterials.
|
|
89
|
+
*/
|
|
90
|
+
function aggregateForFeature(feature, areasToMaterials, areasOpenForOverrideInOption = new Set()) {
|
|
91
|
+
const featureMtrlApplications = feature._internal.mtrlApplications;
|
|
92
|
+
for (const [areaTag, mtrlSource] of reduceApplications(featureMtrlApplications)) {
|
|
93
|
+
// As soon as a Feature sets an areaTag that tag is allowed to have its value
|
|
94
|
+
// overridden (or set if it didn't have a value from the start) by an option.
|
|
95
|
+
// This option has to have an Application with a Mtrl but no AreaTags.
|
|
96
|
+
// And it can only be done once - the first option found which fulfills the
|
|
97
|
+
// requirements will do the override. The option does not even need to be a
|
|
98
|
+
// descendant of the Feature. After this the value is fixed until
|
|
99
|
+
// a Feature or an Option comes along with the AreaTag set.
|
|
100
|
+
// That will then reset the process, and if it was on a Feature it opens for
|
|
101
|
+
// override again.
|
|
102
|
+
areasOpenForOverrideInOption.add(areaTag);
|
|
103
|
+
if (mtrlSource === undefined) {
|
|
104
|
+
areasToMaterials.delete(areaTag);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
areasToMaterials.set(areaTag, mtrlSource);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const option of feature.selectedOptions) {
|
|
111
|
+
aggregateForOption(option, areasToMaterials, areasOpenForOverrideInOption);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function aggregateForOption(option, areasToMaterials, areasOpenForOverrideInOption) {
|
|
115
|
+
const optionMtrlApplications = option._internal.mtrlApplications;
|
|
116
|
+
// The last mtrl with no areaTag can be used for areasOpenForOverrideInOption
|
|
117
|
+
if (areasOpenForOverrideInOption.size !== 0) {
|
|
118
|
+
// Fast backwards loop
|
|
119
|
+
let i = optionMtrlApplications.length;
|
|
120
|
+
while (i--) {
|
|
121
|
+
const optionMtrlApplication = optionMtrlApplications[i];
|
|
122
|
+
const { areaTags, mtrl } = optionMtrlApplication;
|
|
123
|
+
if ((areaTags !== undefined && areaTags.length !== 0) || mtrl === undefined) {
|
|
124
|
+
// Only Applications with a Mtrl but no AreaTags can be used for overrides
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const mtrlSource = {
|
|
128
|
+
mtrl,
|
|
129
|
+
source: optionMtrlApplication,
|
|
130
|
+
overriddenByOption: true,
|
|
131
|
+
};
|
|
132
|
+
for (const areaTag of areasOpenForOverrideInOption) {
|
|
133
|
+
areasToMaterials.set(areaTag, mtrlSource);
|
|
134
|
+
}
|
|
135
|
+
areasOpenForOverrideInOption.clear();
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// reduceApplications will filter out Applications with AreaTags. So there will
|
|
140
|
+
// be no overlap between Applications used for Override and Applications used
|
|
141
|
+
// for immediately setting.
|
|
142
|
+
for (const [areaTag, mtrlSource] of reduceApplications(optionMtrlApplications)) {
|
|
143
|
+
if (mtrlSource === undefined) {
|
|
144
|
+
// An Application on an Option with no Mtrl opens up for a future option
|
|
145
|
+
// to set the Mtrl (the overridden has to be an option with a Mtrl and no Area)
|
|
146
|
+
areasOpenForOverrideInOption.add(areaTag);
|
|
147
|
+
areasToMaterials.delete(areaTag);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
areasToMaterials.set(areaTag, mtrlSource);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
for (const feature of option.features || []) {
|
|
154
|
+
aggregateForFeature(feature, areasToMaterials, areasOpenForOverrideInOption);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export function logMtrlSourceWithMetaDataToConsole(mtrlSourceWithMetaData) {
|
|
158
|
+
const tableData = {
|
|
159
|
+
Source: mtrlSourceWithMetaData.source.source,
|
|
160
|
+
OverriddenByOption: mtrlSourceWithMetaData.overriddenByOption ? "Yes" : "No",
|
|
161
|
+
};
|
|
162
|
+
const mtrl = mtrlSourceWithMetaData.mtrl;
|
|
163
|
+
if (mtrl instanceof CfgMtrlSourceUrl) {
|
|
164
|
+
tableData["From prop"] = mtrl.urlIsFromProperty;
|
|
165
|
+
tableData["url"] = mtrl.url;
|
|
166
|
+
}
|
|
167
|
+
if (mtrl instanceof CfgMtrlSourceBuffer) {
|
|
168
|
+
tableData["FileName"] = mtrl.fileName;
|
|
169
|
+
}
|
|
170
|
+
console.table(tableData);
|
|
171
|
+
}
|
|
172
|
+
export function logMaterialMappingToConsole(areasToMaterials) {
|
|
173
|
+
const sorted = Array.from(areasToMaterials);
|
|
174
|
+
sorted.sort((left, right) => left[0].toLocaleLowerCase().localeCompare(right[0].toLocaleLowerCase()));
|
|
175
|
+
for (const areaToMaterial of sorted) {
|
|
176
|
+
const [tag, mtrlSourceWithMetaData] = areaToMaterial;
|
|
177
|
+
console.groupCollapsed(`"${tag}"`);
|
|
178
|
+
logMtrlSourceWithMetaDataToConsole(mtrlSourceWithMetaData);
|
|
179
|
+
console.groupEnd();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CfgMtrlApplicationSource } from "./CfgMtrlApplicationSource.js";
|
|
3
|
-
import { CfgMtrlSource } from "./CfgMtrlSource.js";
|
|
4
|
-
export declare class CfgMtrlApplication {
|
|
5
|
-
private _source;
|
|
6
|
-
private _areaTags;
|
|
7
|
-
private _mtrl;
|
|
8
|
-
private _previewUrl;
|
|
9
|
-
static fromUrlForDebug(areaTags: string[], url: string): CfgMtrlApplication;
|
|
10
|
-
static fromBufferForDebug(areaTags: string[], fileName: string, buffer: ArrayBuffer): CfgMtrlApplication;
|
|
11
|
-
private static fromMtrlSourceForDebug;
|
|
12
|
-
static fromMtrlLikeApplication(source: CfgMtrlApplicationSource, application:
|
|
13
|
-
private constructor();
|
|
14
|
-
get source(): CfgMtrlApplicationSource;
|
|
15
|
-
get areaTags(): string[] | undefined;
|
|
16
|
-
get mtrl(): CfgMtrlSource | undefined;
|
|
17
|
-
get previewUrl(): string | undefined;
|
|
18
|
-
}
|
|
1
|
+
import { DtoApplicationArea, DtoMtrlApplication } from "../CatalogueAPI.js";
|
|
2
|
+
import { CfgMtrlApplicationSource } from "./CfgMtrlApplicationSource.js";
|
|
3
|
+
import { CfgMtrlSource } from "./CfgMtrlSource.js";
|
|
4
|
+
export declare class CfgMtrlApplication {
|
|
5
|
+
private _source;
|
|
6
|
+
private _areaTags;
|
|
7
|
+
private _mtrl;
|
|
8
|
+
private _previewUrl;
|
|
9
|
+
static fromUrlForDebug(areaTags: string[], url: string): CfgMtrlApplication;
|
|
10
|
+
static fromBufferForDebug(areaTags: string[], fileName: string, buffer: ArrayBuffer): CfgMtrlApplication;
|
|
11
|
+
private static fromMtrlSourceForDebug;
|
|
12
|
+
static fromMtrlLikeApplication(source: CfgMtrlApplicationSource, application: DtoApplicationArea | DtoMtrlApplication): CfgMtrlApplication;
|
|
13
|
+
private constructor();
|
|
14
|
+
get source(): CfgMtrlApplicationSource;
|
|
15
|
+
get areaTags(): string[] | undefined;
|
|
16
|
+
get mtrl(): CfgMtrlSource | undefined;
|
|
17
|
+
get previewUrl(): string | undefined;
|
|
18
|
+
}
|
|
19
19
|
//# sourceMappingURL=CfgMtrlApplication.d.ts.map
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { CfgMtrlApplicationSource } from "./CfgMtrlApplicationSource.js";
|
|
2
|
-
import { CfgMtrlSourceBuffer, CfgMtrlSourceUrl } from "./CfgMtrlSource.js";
|
|
3
|
-
export class CfgMtrlApplication {
|
|
4
|
-
constructor(_source, _areaTags, _mtrl, _previewUrl) {
|
|
5
|
-
this._source = _source;
|
|
6
|
-
this._areaTags = _areaTags;
|
|
7
|
-
this._mtrl = _mtrl;
|
|
8
|
-
this._previewUrl = _previewUrl;
|
|
9
|
-
}
|
|
10
|
-
static fromUrlForDebug(areaTags, url) {
|
|
11
|
-
return this.fromMtrlSourceForDebug(areaTags, new CfgMtrlSourceUrl(url, "debug"));
|
|
12
|
-
}
|
|
13
|
-
static fromBufferForDebug(areaTags, fileName, buffer) {
|
|
14
|
-
return this.fromMtrlSourceForDebug(areaTags, new CfgMtrlSourceBuffer(fileName, buffer));
|
|
15
|
-
}
|
|
16
|
-
static fromMtrlSourceForDebug(areaTags, mtrlSource) {
|
|
17
|
-
const ts = areaTags.filter((t) => t.trim() !== "");
|
|
18
|
-
if (ts.length === 0) {
|
|
19
|
-
throw Error("No tags");
|
|
20
|
-
}
|
|
21
|
-
return new this(CfgMtrlApplicationSource.Debug, areaTags, mtrlSource, undefined);
|
|
22
|
-
}
|
|
23
|
-
static fromMtrlLikeApplication(source, application) {
|
|
24
|
-
const materialUrl = application.material;
|
|
25
|
-
const previewUrl = application.preview;
|
|
26
|
-
const url = materialUrl || previewUrl;
|
|
27
|
-
const urlIsFromProperty = materialUrl ? "material" : "preview";
|
|
28
|
-
const mtrl = url ? new CfgMtrlSourceUrl(url, urlIsFromProperty) : undefined;
|
|
29
|
-
return new this(source, application.areas, mtrl, previewUrl);
|
|
30
|
-
}
|
|
31
|
-
get source() {
|
|
32
|
-
return this._source;
|
|
33
|
-
}
|
|
34
|
-
get areaTags() {
|
|
35
|
-
return this._areaTags;
|
|
36
|
-
}
|
|
37
|
-
get mtrl() {
|
|
38
|
-
return this._mtrl;
|
|
39
|
-
}
|
|
40
|
-
get previewUrl() {
|
|
41
|
-
return this._previewUrl;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
import { CfgMtrlApplicationSource } from "./CfgMtrlApplicationSource.js";
|
|
2
|
+
import { CfgMtrlSourceBuffer, CfgMtrlSourceUrl } from "./CfgMtrlSource.js";
|
|
3
|
+
export class CfgMtrlApplication {
|
|
4
|
+
constructor(_source, _areaTags, _mtrl, _previewUrl) {
|
|
5
|
+
this._source = _source;
|
|
6
|
+
this._areaTags = _areaTags;
|
|
7
|
+
this._mtrl = _mtrl;
|
|
8
|
+
this._previewUrl = _previewUrl;
|
|
9
|
+
}
|
|
10
|
+
static fromUrlForDebug(areaTags, url) {
|
|
11
|
+
return this.fromMtrlSourceForDebug(areaTags, new CfgMtrlSourceUrl(url, "debug"));
|
|
12
|
+
}
|
|
13
|
+
static fromBufferForDebug(areaTags, fileName, buffer) {
|
|
14
|
+
return this.fromMtrlSourceForDebug(areaTags, new CfgMtrlSourceBuffer(fileName, buffer));
|
|
15
|
+
}
|
|
16
|
+
static fromMtrlSourceForDebug(areaTags, mtrlSource) {
|
|
17
|
+
const ts = areaTags.filter((t) => t.trim() !== "");
|
|
18
|
+
if (ts.length === 0) {
|
|
19
|
+
throw Error("No tags");
|
|
20
|
+
}
|
|
21
|
+
return new this(CfgMtrlApplicationSource.Debug, areaTags, mtrlSource, undefined);
|
|
22
|
+
}
|
|
23
|
+
static fromMtrlLikeApplication(source, application) {
|
|
24
|
+
const materialUrl = application.material;
|
|
25
|
+
const previewUrl = application.preview;
|
|
26
|
+
const url = materialUrl || previewUrl;
|
|
27
|
+
const urlIsFromProperty = materialUrl ? "material" : "preview";
|
|
28
|
+
const mtrl = url ? new CfgMtrlSourceUrl(url, urlIsFromProperty) : undefined;
|
|
29
|
+
return new this(source, application.areas, mtrl, previewUrl);
|
|
30
|
+
}
|
|
31
|
+
get source() {
|
|
32
|
+
return this._source;
|
|
33
|
+
}
|
|
34
|
+
get areaTags() {
|
|
35
|
+
return this._areaTags;
|
|
36
|
+
}
|
|
37
|
+
get mtrl() {
|
|
38
|
+
return this._mtrl;
|
|
39
|
+
}
|
|
40
|
+
get previewUrl() {
|
|
41
|
+
return this._previewUrl;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare enum CfgMtrlApplicationSource {
|
|
2
|
-
ApplicationArea = "ApplicationArea",
|
|
3
|
-
Product = "Product",
|
|
4
|
-
Feature = "Feature",
|
|
5
|
-
Option = "Option",
|
|
6
|
-
Debug = "Debug"
|
|
7
|
-
}
|
|
1
|
+
export declare enum CfgMtrlApplicationSource {
|
|
2
|
+
ApplicationArea = "ApplicationArea",
|
|
3
|
+
Product = "Product",
|
|
4
|
+
Feature = "Feature",
|
|
5
|
+
Option = "Option",
|
|
6
|
+
Debug = "Debug"
|
|
7
|
+
}
|
|
8
8
|
//# sourceMappingURL=CfgMtrlApplicationSource.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export var CfgMtrlApplicationSource;
|
|
2
|
-
(function (CfgMtrlApplicationSource) {
|
|
3
|
-
CfgMtrlApplicationSource["ApplicationArea"] = "ApplicationArea";
|
|
4
|
-
CfgMtrlApplicationSource["Product"] = "Product";
|
|
5
|
-
CfgMtrlApplicationSource["Feature"] = "Feature";
|
|
6
|
-
CfgMtrlApplicationSource["Option"] = "Option";
|
|
7
|
-
CfgMtrlApplicationSource["Debug"] = "Debug";
|
|
8
|
-
})(CfgMtrlApplicationSource || (CfgMtrlApplicationSource = {}));
|
|
1
|
+
export var CfgMtrlApplicationSource;
|
|
2
|
+
(function (CfgMtrlApplicationSource) {
|
|
3
|
+
CfgMtrlApplicationSource["ApplicationArea"] = "ApplicationArea";
|
|
4
|
+
CfgMtrlApplicationSource["Product"] = "Product";
|
|
5
|
+
CfgMtrlApplicationSource["Feature"] = "Feature";
|
|
6
|
+
CfgMtrlApplicationSource["Option"] = "Option";
|
|
7
|
+
CfgMtrlApplicationSource["Debug"] = "Debug";
|
|
8
|
+
})(CfgMtrlApplicationSource || (CfgMtrlApplicationSource = {}));
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export declare abstract class CfgMtrlSource {
|
|
2
|
-
abstract isSame(other: CfgMtrlSource): boolean;
|
|
3
|
-
}
|
|
4
|
-
export declare class CfgMtrlSourceUrl extends CfgMtrlSource {
|
|
5
|
-
private _url;
|
|
6
|
-
private _urlIsFromProperty;
|
|
7
|
-
constructor(_url: string, _urlIsFromProperty: string);
|
|
8
|
-
get url(): string;
|
|
9
|
-
get urlIsFromProperty(): string;
|
|
10
|
-
isSame(other: CfgMtrlSource): boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare class CfgMtrlSourceBuffer extends CfgMtrlSource {
|
|
13
|
-
private _fileName;
|
|
14
|
-
private _buffer;
|
|
15
|
-
constructor(_fileName: string, _buffer: ArrayBuffer);
|
|
16
|
-
get fileName(): string;
|
|
17
|
-
get buffer(): ArrayBuffer;
|
|
18
|
-
isSame(other: CfgMtrlSource): boolean;
|
|
19
|
-
}
|
|
1
|
+
export declare abstract class CfgMtrlSource {
|
|
2
|
+
abstract isSame(other: CfgMtrlSource): boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare class CfgMtrlSourceUrl extends CfgMtrlSource {
|
|
5
|
+
private _url;
|
|
6
|
+
private _urlIsFromProperty;
|
|
7
|
+
constructor(_url: string, _urlIsFromProperty: string);
|
|
8
|
+
get url(): string;
|
|
9
|
+
get urlIsFromProperty(): string;
|
|
10
|
+
isSame(other: CfgMtrlSource): boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class CfgMtrlSourceBuffer extends CfgMtrlSource {
|
|
13
|
+
private _fileName;
|
|
14
|
+
private _buffer;
|
|
15
|
+
constructor(_fileName: string, _buffer: ArrayBuffer);
|
|
16
|
+
get fileName(): string;
|
|
17
|
+
get buffer(): ArrayBuffer;
|
|
18
|
+
isSame(other: CfgMtrlSource): boolean;
|
|
19
|
+
}
|
|
20
20
|
//# sourceMappingURL=CfgMtrlSource.d.ts.map
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
export class CfgMtrlSource {
|
|
2
|
-
}
|
|
3
|
-
export class CfgMtrlSourceUrl extends CfgMtrlSource {
|
|
4
|
-
constructor(_url, _urlIsFromProperty) {
|
|
5
|
-
super();
|
|
6
|
-
this._url = _url;
|
|
7
|
-
this._urlIsFromProperty = _urlIsFromProperty;
|
|
8
|
-
}
|
|
9
|
-
get url() {
|
|
10
|
-
return this._url;
|
|
11
|
-
}
|
|
12
|
-
get urlIsFromProperty() {
|
|
13
|
-
return this._urlIsFromProperty;
|
|
14
|
-
}
|
|
15
|
-
isSame(other) {
|
|
16
|
-
if (!(other instanceof CfgMtrlSourceUrl)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return this.url === other.url;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export class CfgMtrlSourceBuffer extends CfgMtrlSource {
|
|
23
|
-
constructor(_fileName, _buffer) {
|
|
24
|
-
super();
|
|
25
|
-
this._fileName = _fileName;
|
|
26
|
-
this._buffer = _buffer;
|
|
27
|
-
}
|
|
28
|
-
get fileName() {
|
|
29
|
-
return this._fileName;
|
|
30
|
-
}
|
|
31
|
-
get buffer() {
|
|
32
|
-
return this._buffer;
|
|
33
|
-
}
|
|
34
|
-
isSame(other) {
|
|
35
|
-
if (!(other instanceof CfgMtrlSourceBuffer)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
return this.fileName === other.fileName;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
export class CfgMtrlSource {
|
|
2
|
+
}
|
|
3
|
+
export class CfgMtrlSourceUrl extends CfgMtrlSource {
|
|
4
|
+
constructor(_url, _urlIsFromProperty) {
|
|
5
|
+
super();
|
|
6
|
+
this._url = _url;
|
|
7
|
+
this._urlIsFromProperty = _urlIsFromProperty;
|
|
8
|
+
}
|
|
9
|
+
get url() {
|
|
10
|
+
return this._url;
|
|
11
|
+
}
|
|
12
|
+
get urlIsFromProperty() {
|
|
13
|
+
return this._urlIsFromProperty;
|
|
14
|
+
}
|
|
15
|
+
isSame(other) {
|
|
16
|
+
if (!(other instanceof CfgMtrlSourceUrl)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return this.url === other.url;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class CfgMtrlSourceBuffer extends CfgMtrlSource {
|
|
23
|
+
constructor(_fileName, _buffer) {
|
|
24
|
+
super();
|
|
25
|
+
this._fileName = _fileName;
|
|
26
|
+
this._buffer = _buffer;
|
|
27
|
+
}
|
|
28
|
+
get fileName() {
|
|
29
|
+
return this._fileName;
|
|
30
|
+
}
|
|
31
|
+
get buffer() {
|
|
32
|
+
return this._buffer;
|
|
33
|
+
}
|
|
34
|
+
isSame(other) {
|
|
35
|
+
if (!(other instanceof CfgMtrlSourceBuffer)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return this.fileName === other.fileName;
|
|
39
|
+
}
|
|
40
|
+
}
|