@configura/web-api 2.0.0-alpha.2 → 2.0.0-alpha.21
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 -18
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +597 -551
- package/dist/CatalogueAPI.js +328 -293
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +328 -268
- package/dist/CfgProduct.js +934 -778
- package/dist/CfgReferencePathHelper.d.ts +26 -13
- package/dist/CfgReferencePathHelper.js +26 -13
- package/dist/ConfigurationConverter.d.ts +17 -4
- package/dist/ConfigurationConverter.js +175 -72
- package/dist/index.d.ts +23 -23
- package/dist/index.js +23 -23
- package/dist/io/CfgHistoryManager.d.ts +83 -50
- package/dist/io/CfgHistoryManager.js +144 -82
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -20
- package/dist/io/CfgHistoryToProdConfConnector.js +50 -56
- package/dist/io/CfgIOManager.d.ts +53 -48
- package/dist/io/CfgIOManager.js +134 -115
- package/dist/io/CfgIOProdConfConnector.d.ts +64 -52
- package/dist/io/CfgIOProdConfConnector.js +149 -141
- package/dist/io/CfgIOWarningSupplier.d.ts +4 -0
- package/dist/io/CfgIOWarningSupplier.js +1 -0
- package/dist/io/CfgObservableStateManager.d.ts +25 -21
- package/dist/io/CfgObservableStateManager.js +69 -65
- package/dist/io/CfgObservableStateToProdConfConnector.d.ts +14 -14
- package/dist/io/CfgObservableStateToProdConfConnector.js +16 -16
- 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 -84
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +16 -16
- package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -18
- 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 +189 -187
- package/dist/productConfiguration/CfgFeature.js +658 -645
- package/dist/productConfiguration/CfgOption.d.ts +151 -151
- package/dist/productConfiguration/CfgOption.js +422 -416
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +129 -117
- package/dist/productConfiguration/CfgProductConfiguration.js +340 -307
- 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 +87 -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 +47 -40
- package/dist/syncGroups/SyncGroupsHandler.js +370 -359
- package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
- package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
- package/dist/syncGroups/SyncGroupsState.d.ts +39 -35
- package/dist/syncGroups/SyncGroupsState.js +167 -125
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
- package/dist/syncGroups/SyncGroupsTransaction.js +589 -576
- package/dist/tasks/TaskHandler.d.ts +77 -77
- package/dist/tasks/TaskHandler.js +276 -275
- 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 -277
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +187 -185
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +185 -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 +189 -187
- package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
- package/dist/tests/testData/testDataUpcharge.js +121 -119
- package/dist/utilitiesCatalogueData.d.ts +47 -42
- package/dist/utilitiesCatalogueData.js +180 -173
- package/dist/utilitiesCataloguePermission.d.ts +38 -38
- package/dist/utilitiesCataloguePermission.js +79 -79
- package/dist/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +114 -109
- package/package.json +3 -3
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* These methods aims to provide a default suggested way of building
|
|
4
|
-
* URLs to Products and Catalogues. By using consistent URL:s copy-paste
|
|
5
|
-
* between systems becomes easy and this can aid when debugging.
|
|
6
|
-
* Using this format on URL is no requirement. In fact, most of our
|
|
7
|
-
* integrators do not, as they do not expose the Catalogue-path.
|
|
8
|
-
* Internally at Configura we try to stick with this format.
|
|
9
|
-
*/
|
|
10
|
-
export declare class CfgReferencePathHelper {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { DtoCatalogueParamsWithCidAndLang, DtoProductParamsWithCidAndLang } from "./CatalogueAPI";
|
|
2
|
+
/**
|
|
3
|
+
* These methods aims to provide a default suggested way of building
|
|
4
|
+
* URLs to Products and Catalogues. By using consistent URL:s copy-paste
|
|
5
|
+
* between systems becomes easy and this can aid when debugging.
|
|
6
|
+
* Using this format on URL is no requirement. In fact, most of our
|
|
7
|
+
* integrators do not, as they do not expose the Catalogue-path.
|
|
8
|
+
* Internally at Configura we try to stick with this format.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CfgReferencePathHelper {
|
|
11
|
+
/**
|
|
12
|
+
* Use to generate URLs in our reference format. This is the format Configura uses in our integrations.
|
|
13
|
+
* @param browsingRootUrl The URL where Stage browsing begins
|
|
14
|
+
* @param catParams What catalogue to generate URL for.
|
|
15
|
+
* @returns An URL to a catalogue
|
|
16
|
+
*/
|
|
17
|
+
static getCataloguePath: (browsingRootUrl: string, catParams: DtoCatalogueParamsWithCidAndLang) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Use to generate URLs in our reference format. This is the format Configura uses in our integrations.
|
|
20
|
+
* @param browsingRootUrl The URL where Stage browsing begins
|
|
21
|
+
* @param productParams What product to generate URL for.
|
|
22
|
+
* @param separator Optional, defaults to "product", but can be changed to indicate another function.
|
|
23
|
+
* @returns An URL to a product
|
|
24
|
+
*/
|
|
25
|
+
static getProductPath: (browsingRootUrl: string, productParams: DtoProductParamsWithCidAndLang, separator?: string) => string;
|
|
26
|
+
}
|
|
14
27
|
//# sourceMappingURL=CfgReferencePathHelper.d.ts.map
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import { encodeURIComponents } from "@configura/web-utilities";
|
|
2
|
-
/**
|
|
3
|
-
* These methods aims to provide a default suggested way of building
|
|
4
|
-
* URLs to Products and Catalogues. By using consistent URL:s copy-paste
|
|
5
|
-
* between systems becomes easy and this can aid when debugging.
|
|
6
|
-
* Using this format on URL is no requirement. In fact, most of our
|
|
7
|
-
* integrators do not, as they do not expose the Catalogue-path.
|
|
8
|
-
* Internally at Configura we try to stick with this format.
|
|
9
|
-
*/
|
|
10
|
-
export class CfgReferencePathHelper {
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { encodeURIComponents } from "@configura/web-utilities";
|
|
2
|
+
/**
|
|
3
|
+
* These methods aims to provide a default suggested way of building
|
|
4
|
+
* URLs to Products and Catalogues. By using consistent URL:s copy-paste
|
|
5
|
+
* between systems becomes easy and this can aid when debugging.
|
|
6
|
+
* Using this format on URL is no requirement. In fact, most of our
|
|
7
|
+
* integrators do not, as they do not expose the Catalogue-path.
|
|
8
|
+
* Internally at Configura we try to stick with this format.
|
|
9
|
+
*/
|
|
10
|
+
export class CfgReferencePathHelper {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Use to generate URLs in our reference format. This is the format Configura uses in our integrations.
|
|
14
|
+
* @param browsingRootUrl The URL where Stage browsing begins
|
|
15
|
+
* @param catParams What catalogue to generate URL for.
|
|
16
|
+
* @returns An URL to a catalogue
|
|
17
|
+
*/
|
|
18
|
+
CfgReferencePathHelper.getCataloguePath = (browsingRootUrl, catParams) => `${browsingRootUrl}/${encodeURIComponents(catParams.cid, catParams.lang, catParams.enterprise, catParams.prdCat, catParams.prdCatVersion, catParams.vendor, catParams.priceList)}`;
|
|
19
|
+
/**
|
|
20
|
+
* Use to generate URLs in our reference format. This is the format Configura uses in our integrations.
|
|
21
|
+
* @param browsingRootUrl The URL where Stage browsing begins
|
|
22
|
+
* @param productParams What product to generate URL for.
|
|
23
|
+
* @param separator Optional, defaults to "product", but can be changed to indicate another function.
|
|
24
|
+
* @returns An URL to a product
|
|
25
|
+
*/
|
|
26
|
+
CfgReferencePathHelper.getProductPath = (browsingRootUrl, productParams, separator = "product") => `${CfgReferencePathHelper.getCataloguePath(browsingRootUrl, productParams)}/${separator}/${encodeURIComponent(productParams.partNumber)}`;
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
1
|
+
import { DtoAdditionalProductConf, DtoAdditionalProductConfiguration, DtoFeatureConf, DtoProductConf, DtoSelectedOption } from "./CatalogueAPI.js";
|
|
2
|
+
/** Is the newer version of product configuration */
|
|
3
|
+
export declare const isProductConf: (value: DtoAdditionalProductConfiguration | DtoProductConf) => value is DtoAdditionalProductConf;
|
|
4
|
+
/** Is the older version of product configuration */
|
|
5
|
+
export declare const isAdditionalProductConfiguration: (value: DtoAdditionalProductConfiguration | DtoProductConf) => value is DtoAdditionalProductConfiguration;
|
|
6
|
+
export declare const isDtoProductConfAdditional: (value: DtoProductConf) => value is DtoAdditionalProductConf;
|
|
7
|
+
export declare const convertDtoProductConfToV1: (conf: DtoProductConf, silenceWarnings?: boolean) => DtoAdditionalProductConfiguration;
|
|
8
|
+
export declare const convertDtoFeatureConfsToSelOptions: (features: DtoFeatureConf[], silenceWarnings?: boolean) => DtoSelectedOption[];
|
|
9
|
+
/**
|
|
10
|
+
* Serializes and compacts the configuration into a format especially suited for URLs
|
|
11
|
+
*/
|
|
12
|
+
export declare const dtoProductConfigurationToCompactString: (conf: DtoProductConf) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Deserializes and inflates the configuration from the compacted format
|
|
15
|
+
*/
|
|
16
|
+
export declare const compactStringToDtoProductConf: (versionAndConf: string) => DtoProductConf;
|
|
17
|
+
export declare const stripExtendedDataFromDtoProductConf: (conf: DtoProductConf) => DtoProductConf;
|
|
5
18
|
//# sourceMappingURL=ConfigurationConverter.d.ts.map
|
|
@@ -1,72 +1,175 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
if (!silenceWarnings &&
|
|
37
|
-
|
|
38
|
-
console.info("Incoming DtoFeature contains
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
mergedSelectionTree[key]
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
1
|
+
/** Is the newer version of product configuration */
|
|
2
|
+
export const isProductConf = (value) => !("selOptions" in value);
|
|
3
|
+
/** Is the older version of product configuration */
|
|
4
|
+
export const isAdditionalProductConfiguration = (value) => "selOptions" in value;
|
|
5
|
+
export const isDtoProductConfAdditional = (value) => "refKey" in value;
|
|
6
|
+
// As this has potential to flood the terminal we only inform once
|
|
7
|
+
let hasInformedAboutProdParams = false;
|
|
8
|
+
let hasInformedAboutGroupCode = false;
|
|
9
|
+
let hasInformedAboutUnit = false;
|
|
10
|
+
export const convertDtoProductConfToV1 = (conf, silenceWarnings = false) => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
if (!silenceWarnings && conf.prodParams !== undefined && !hasInformedAboutProdParams) {
|
|
13
|
+
hasInformedAboutProdParams = true;
|
|
14
|
+
console.info("Incoming DtoProductConf contains prodParams. These will be ignored.");
|
|
15
|
+
}
|
|
16
|
+
const result = {
|
|
17
|
+
selOptions: ((_a = conf.features) !== null && _a !== void 0 ? _a : []).map((f) => ({
|
|
18
|
+
code: "!~!",
|
|
19
|
+
next: convertDtoFeatureConfToApiSelection(f, silenceWarnings),
|
|
20
|
+
})),
|
|
21
|
+
additionalProducts: ((_b = conf.additionalProducts) !== null && _b !== void 0 ? _b : []).map((p) => convertDtoProductConfToV1(p, silenceWarnings)),
|
|
22
|
+
selected: true,
|
|
23
|
+
};
|
|
24
|
+
if (isDtoProductConfAdditional(conf)) {
|
|
25
|
+
result.refKey = conf.refKey;
|
|
26
|
+
result.selected = conf.selected;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
export const convertDtoFeatureConfsToSelOptions = (features, silenceWarnings = false) => (features !== null && features !== void 0 ? features : []).map((f) => ({
|
|
31
|
+
code: "!~!",
|
|
32
|
+
next: convertDtoFeatureConfToApiSelection(f, silenceWarnings),
|
|
33
|
+
}));
|
|
34
|
+
const convertDtoFeatureConfToApiSelection = (feature, silenceWarnings) => {
|
|
35
|
+
const { groupCode, options, unit } = feature;
|
|
36
|
+
if (!silenceWarnings && groupCode !== undefined && !hasInformedAboutGroupCode) {
|
|
37
|
+
hasInformedAboutGroupCode = true;
|
|
38
|
+
console.info("Incoming DtoFeature contains groupCode. It will be ignored.");
|
|
39
|
+
}
|
|
40
|
+
if (!silenceWarnings && unit !== undefined && !hasInformedAboutUnit) {
|
|
41
|
+
hasInformedAboutUnit = true;
|
|
42
|
+
console.info("Incoming DtoFeature contains a unit. It will be ignored.");
|
|
43
|
+
}
|
|
44
|
+
const result = {};
|
|
45
|
+
for (const option of (options !== null && options !== void 0 ? options : []).filter((o) => o.selected)) {
|
|
46
|
+
result[option.code] = convertDtoOptionConfToSelectedOption(option, silenceWarnings);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
const convertDtoOptionConfToSelectedOption = (option, silenceWarnings) => {
|
|
51
|
+
const { features, code, numericValue } = option;
|
|
52
|
+
const selectionTrees = (features !== null && features !== void 0 ? features : []).map((f) => convertDtoFeatureConfToApiSelection(f, silenceWarnings));
|
|
53
|
+
const mergedSelectionTree = {};
|
|
54
|
+
let anyItems = false;
|
|
55
|
+
for (const selectionTree of selectionTrees) {
|
|
56
|
+
if (selectionTree === undefined) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
for (const key of Object.keys(selectionTree)) {
|
|
60
|
+
if (mergedSelectionTree[key] !== undefined) {
|
|
61
|
+
console.warn(`The key (${key}) is already used in the selection tree. Option code: "${code}".`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
mergedSelectionTree[key] = selectionTree[key];
|
|
65
|
+
anyItems = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const selectedOption = {
|
|
69
|
+
code,
|
|
70
|
+
numericValue,
|
|
71
|
+
};
|
|
72
|
+
if (anyItems) {
|
|
73
|
+
selectedOption.next = mergedSelectionTree;
|
|
74
|
+
}
|
|
75
|
+
return selectedOption;
|
|
76
|
+
};
|
|
77
|
+
const versionedRegex = /^v(\d+)(.+)$/;
|
|
78
|
+
const jsonKeyRegex = /"([^"]+)":/g;
|
|
79
|
+
const swapForUrlAdaptedRegex = /[-~_{}"]/g;
|
|
80
|
+
const shortToLong = new Map();
|
|
81
|
+
const longToShort = new Map();
|
|
82
|
+
// The replacement scheme here assumes this will only be used for keys
|
|
83
|
+
// in DtoProductConf and the knowledge that it contains no one
|
|
84
|
+
// one char keys.
|
|
85
|
+
for (const [long, short] of [
|
|
86
|
+
["configuration", "c"],
|
|
87
|
+
["additionalProducts", "a"],
|
|
88
|
+
["prodParams", "p"],
|
|
89
|
+
["refKey", "r"],
|
|
90
|
+
["selected", "s"],
|
|
91
|
+
["features", "f"],
|
|
92
|
+
["code", "d"],
|
|
93
|
+
["options", "o"],
|
|
94
|
+
["numericValue", "n"],
|
|
95
|
+
["groupCode", "g"],
|
|
96
|
+
["unit", "u"],
|
|
97
|
+
["syncGroupState", "sgs"],
|
|
98
|
+
["selectOne", "so"],
|
|
99
|
+
["selectMany", "sm"],
|
|
100
|
+
["syncCode", "sc"],
|
|
101
|
+
["optionCode", "oc"],
|
|
102
|
+
]) {
|
|
103
|
+
shortToLong.set(short, long);
|
|
104
|
+
longToShort.set(long, short);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* As certain chars are abundant in JSON but less abundant in the actual data
|
|
108
|
+
* we swap these so that frequent characters do not need to be URL-encoded.
|
|
109
|
+
*/
|
|
110
|
+
const jsonStringSwapCharsForUrl = (data) => data.replace(swapForUrlAdaptedRegex, (char) => {
|
|
111
|
+
switch (char) {
|
|
112
|
+
case "{":
|
|
113
|
+
return "~";
|
|
114
|
+
case "}":
|
|
115
|
+
return "-";
|
|
116
|
+
case '"':
|
|
117
|
+
return "_";
|
|
118
|
+
case "~":
|
|
119
|
+
return "{";
|
|
120
|
+
case "-":
|
|
121
|
+
return "}";
|
|
122
|
+
case "_":
|
|
123
|
+
return '"';
|
|
124
|
+
default:
|
|
125
|
+
throw new Error(`Unexpected char "${char}" in swap for URL`);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const compactDtoProductConfJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => { var _a; return `"${(_a = longToShort.get(key)) !== null && _a !== void 0 ? _a : key}":`; });
|
|
129
|
+
const expandDtoProductConfJsonKeys = (data) => data.replace(jsonKeyRegex, (_, key) => { var _a; return `"${(_a = shortToLong.get(key)) !== null && _a !== void 0 ? _a : key}":`; });
|
|
130
|
+
/**
|
|
131
|
+
* Serializes and compacts the configuration into a format especially suited for URLs
|
|
132
|
+
*/
|
|
133
|
+
export const dtoProductConfigurationToCompactString = (conf) => "v1" +
|
|
134
|
+
jsonStringSwapCharsForUrl(compactDtoProductConfJsonKeys(JSON.stringify(conf, undefined, "")));
|
|
135
|
+
/**
|
|
136
|
+
* Deserializes and inflates the configuration from the compacted format
|
|
137
|
+
*/
|
|
138
|
+
export const compactStringToDtoProductConf = (versionAndConf) => {
|
|
139
|
+
const match = versionedRegex.exec(versionAndConf);
|
|
140
|
+
if (match === null) {
|
|
141
|
+
throw new Error("Could not match version string");
|
|
142
|
+
}
|
|
143
|
+
const [, version, conf] = match;
|
|
144
|
+
if (version !== "1") {
|
|
145
|
+
throw new Error("Unknown packed URL version");
|
|
146
|
+
}
|
|
147
|
+
if (conf === "") {
|
|
148
|
+
throw new Error("No conf found");
|
|
149
|
+
}
|
|
150
|
+
return JSON.parse(expandDtoProductConfJsonKeys(jsonStringSwapCharsForUrl(conf)));
|
|
151
|
+
};
|
|
152
|
+
export const stripExtendedDataFromDtoProductConf = (conf) => {
|
|
153
|
+
var _a, _b;
|
|
154
|
+
return ({
|
|
155
|
+
features: (_a = conf.features) === null || _a === void 0 ? void 0 : _a.map(stripExtendedDataFromDtoFeatureConf),
|
|
156
|
+
additionalProducts: (_b = conf.additionalProducts) === null || _b === void 0 ? void 0 : _b.map(stripExtendedDataFromDtoAdditionalProductConfiguration),
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
const stripExtendedDataFromDtoAdditionalProductConfiguration = (conf) => (Object.assign(Object.assign({}, stripExtendedDataFromDtoProductConf(conf)), { refKey: conf.refKey, selected: conf.selected }));
|
|
160
|
+
const stripExtendedDataFromDtoFeatureConf = (conf) => {
|
|
161
|
+
var _a;
|
|
162
|
+
return ({
|
|
163
|
+
code: conf.code,
|
|
164
|
+
options: (_a = conf.options) === null || _a === void 0 ? void 0 : _a.map(stripExtendedDataFromDtoOptionConf),
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
const stripExtendedDataFromDtoOptionConf = (conf) => {
|
|
168
|
+
var _a;
|
|
169
|
+
return ({
|
|
170
|
+
code: conf.code,
|
|
171
|
+
selected: conf.selected,
|
|
172
|
+
numericValue: conf.numericValue,
|
|
173
|
+
features: (_a = conf.features) === null || _a === void 0 ? void 0 : _a.map(stripExtendedDataFromDtoFeatureConf),
|
|
174
|
+
});
|
|
175
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export * from "./CatalogueAPI.js";
|
|
2
|
-
export * from "./CfgProduct.js";
|
|
3
|
-
export * from "./CfgReferencePathHelper.js";
|
|
4
|
-
export * from "./ConfigurationConverter.js";
|
|
5
|
-
export * from "./io/index.js";
|
|
6
|
-
export * from "./material/CfgMaterialMapping.js";
|
|
7
|
-
export * from "./material/CfgMtrlApplication.js";
|
|
8
|
-
export * from "./material/CfgMtrlApplicationSource.js";
|
|
9
|
-
export * from "./material/CfgMtrlSource.js";
|
|
10
|
-
export * from "./material/CfgMtrlSourceWithMetaData.js";
|
|
11
|
-
export * from "./productConfiguration/CfgFeature.js";
|
|
12
|
-
export * from "./productConfiguration/CfgOption.js";
|
|
13
|
-
export * from "./productConfiguration/CfgProductConfiguration.js";
|
|
14
|
-
export * from "./productConfiguration/filters.js";
|
|
15
|
-
export * from "./productConfiguration/productParamsGenerator.js";
|
|
16
|
-
export * from "./productLoader.js";
|
|
17
|
-
export * from "./syncGroups/SyncGroupsApplyMode.js";
|
|
18
|
-
export * from "./syncGroups/SyncGroupsHandler.js";
|
|
19
|
-
export * from "./tasks/formats.js";
|
|
20
|
-
export * from "./tasks/TaskHandler.js";
|
|
21
|
-
export * from "./utilitiesCatalogueData.js";
|
|
22
|
-
export * from "./utilitiesCataloguePermission.js";
|
|
23
|
-
export * from "./utilitiesNumericValues.js";
|
|
1
|
+
export * from "./CatalogueAPI.js";
|
|
2
|
+
export * from "./CfgProduct.js";
|
|
3
|
+
export * from "./CfgReferencePathHelper.js";
|
|
4
|
+
export * from "./ConfigurationConverter.js";
|
|
5
|
+
export * from "./io/index.js";
|
|
6
|
+
export * from "./material/CfgMaterialMapping.js";
|
|
7
|
+
export * from "./material/CfgMtrlApplication.js";
|
|
8
|
+
export * from "./material/CfgMtrlApplicationSource.js";
|
|
9
|
+
export * from "./material/CfgMtrlSource.js";
|
|
10
|
+
export * from "./material/CfgMtrlSourceWithMetaData.js";
|
|
11
|
+
export * from "./productConfiguration/CfgFeature.js";
|
|
12
|
+
export * from "./productConfiguration/CfgOption.js";
|
|
13
|
+
export * from "./productConfiguration/CfgProductConfiguration.js";
|
|
14
|
+
export * from "./productConfiguration/filters.js";
|
|
15
|
+
export * from "./productConfiguration/productParamsGenerator.js";
|
|
16
|
+
export * from "./productLoader.js";
|
|
17
|
+
export * from "./syncGroups/SyncGroupsApplyMode.js";
|
|
18
|
+
export * from "./syncGroups/SyncGroupsHandler.js";
|
|
19
|
+
export * from "./tasks/formats.js";
|
|
20
|
+
export * from "./tasks/TaskHandler.js";
|
|
21
|
+
export * from "./utilitiesCatalogueData.js";
|
|
22
|
+
export * from "./utilitiesCataloguePermission.js";
|
|
23
|
+
export * from "./utilitiesNumericValues.js";
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export * from "./CatalogueAPI.js";
|
|
2
|
-
export * from "./CfgProduct.js";
|
|
3
|
-
export * from "./CfgReferencePathHelper.js";
|
|
4
|
-
export * from "./ConfigurationConverter.js";
|
|
5
|
-
export * from "./io/index.js";
|
|
6
|
-
export * from "./material/CfgMaterialMapping.js";
|
|
7
|
-
export * from "./material/CfgMtrlApplication.js";
|
|
8
|
-
export * from "./material/CfgMtrlApplicationSource.js";
|
|
9
|
-
export * from "./material/CfgMtrlSource.js";
|
|
10
|
-
export * from "./material/CfgMtrlSourceWithMetaData.js";
|
|
11
|
-
export * from "./productConfiguration/CfgFeature.js";
|
|
12
|
-
export * from "./productConfiguration/CfgOption.js";
|
|
13
|
-
export * from "./productConfiguration/CfgProductConfiguration.js";
|
|
14
|
-
export * from "./productConfiguration/filters.js";
|
|
15
|
-
export * from "./productConfiguration/productParamsGenerator.js";
|
|
16
|
-
export * from "./productLoader.js";
|
|
17
|
-
export * from "./syncGroups/SyncGroupsApplyMode.js";
|
|
18
|
-
export * from "./syncGroups/SyncGroupsHandler.js";
|
|
19
|
-
export * from "./tasks/formats.js";
|
|
20
|
-
export * from "./tasks/TaskHandler.js";
|
|
21
|
-
export * from "./utilitiesCatalogueData.js";
|
|
22
|
-
export * from "./utilitiesCataloguePermission.js";
|
|
23
|
-
export * from "./utilitiesNumericValues.js";
|
|
1
|
+
export * from "./CatalogueAPI.js";
|
|
2
|
+
export * from "./CfgProduct.js";
|
|
3
|
+
export * from "./CfgReferencePathHelper.js";
|
|
4
|
+
export * from "./ConfigurationConverter.js";
|
|
5
|
+
export * from "./io/index.js";
|
|
6
|
+
export * from "./material/CfgMaterialMapping.js";
|
|
7
|
+
export * from "./material/CfgMtrlApplication.js";
|
|
8
|
+
export * from "./material/CfgMtrlApplicationSource.js";
|
|
9
|
+
export * from "./material/CfgMtrlSource.js";
|
|
10
|
+
export * from "./material/CfgMtrlSourceWithMetaData.js";
|
|
11
|
+
export * from "./productConfiguration/CfgFeature.js";
|
|
12
|
+
export * from "./productConfiguration/CfgOption.js";
|
|
13
|
+
export * from "./productConfiguration/CfgProductConfiguration.js";
|
|
14
|
+
export * from "./productConfiguration/filters.js";
|
|
15
|
+
export * from "./productConfiguration/productParamsGenerator.js";
|
|
16
|
+
export * from "./productLoader.js";
|
|
17
|
+
export * from "./syncGroups/SyncGroupsApplyMode.js";
|
|
18
|
+
export * from "./syncGroups/SyncGroupsHandler.js";
|
|
19
|
+
export * from "./tasks/formats.js";
|
|
20
|
+
export * from "./tasks/TaskHandler.js";
|
|
21
|
+
export * from "./utilitiesCatalogueData.js";
|
|
22
|
+
export * from "./utilitiesCataloguePermission.js";
|
|
23
|
+
export * from "./utilitiesNumericValues.js";
|
|
@@ -1,51 +1,84 @@
|
|
|
1
|
-
import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
|
|
2
|
-
declare type CfgHistoryManagerMessageData = {
|
|
3
|
-
initial: boolean;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
private static
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
|
|
2
|
+
declare type CfgHistoryManagerMessageData = {
|
|
3
|
+
initial: boolean;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* How the history is updated.
|
|
7
|
+
* @param DoNotWrite Only listens to initial URL-values.
|
|
8
|
+
* @param Replace Replaces the current history frame at updates.
|
|
9
|
+
* @param Push Adds history frames at updates.
|
|
10
|
+
* @param ReplaceAndUpdateUrl Replaces the current history frame at updates and updates the browser URL
|
|
11
|
+
* @param PushAndUpdateUrl Adds history frames at updates and updates the browser URL
|
|
12
|
+
*/
|
|
13
|
+
export declare enum HistoryMode {
|
|
14
|
+
DoNotWrite = 0,
|
|
15
|
+
Replace = 1,
|
|
16
|
+
Push = 2,
|
|
17
|
+
ReplaceAndUpdateUrl = 3,
|
|
18
|
+
PushAndUpdateUrl = 4
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The collected data used when sending. For history this both contains the message, which is
|
|
22
|
+
* used as the "state" in the history-frame, and the qsKeyValues, which are query string
|
|
23
|
+
* key-values used in the URL.
|
|
24
|
+
* When navigating back and forth the stage (message) is used to restore the old state. When
|
|
25
|
+
* opening a window with no prior history the Query String will be used.
|
|
26
|
+
*/
|
|
27
|
+
export declare type CfgHistoryManagerSendData<D> = {
|
|
28
|
+
message: D;
|
|
29
|
+
mode: HistoryMode;
|
|
30
|
+
qsKeyValues: Map<string, string | undefined>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* This class is used to coordinate writing and reading to the browser history.
|
|
34
|
+
* It handles messages sent from the connectors.
|
|
35
|
+
*/
|
|
36
|
+
export declare class CfgHistoryManager extends CfgWindowEventManager<"popstate", CfgHistoryManagerSendData<CfgHistoryManagerMessageData>> {
|
|
37
|
+
private static _instance;
|
|
38
|
+
static get instance(): CfgHistoryManager;
|
|
39
|
+
private constructor();
|
|
40
|
+
private _aggregatedQsKeyValues;
|
|
41
|
+
private _urlUpdateObservable;
|
|
42
|
+
/**
|
|
43
|
+
* @returns The current browser URL updated with the latest updates from
|
|
44
|
+
* the Connectors.
|
|
45
|
+
*/
|
|
46
|
+
getUrl(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Listen for updated URL:s. This doesn't have to mean the URL in the
|
|
49
|
+
* browser has been updated.
|
|
50
|
+
*/
|
|
51
|
+
listenForUrl(listener: (url: string) => void): void;
|
|
52
|
+
/**
|
|
53
|
+
* Stop listen.
|
|
54
|
+
*/
|
|
55
|
+
stopListenForUrl(listener: (url: string) => void): void;
|
|
56
|
+
/**
|
|
57
|
+
* Write to the history
|
|
58
|
+
*/
|
|
59
|
+
send(messageKey: string, data: CfgHistoryManagerSendData<CfgHistoryManagerMessageData>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Takes the current in browser URL and updates it with the provided Query String values.
|
|
62
|
+
* Old Query String is replaced.
|
|
63
|
+
*/
|
|
64
|
+
private static _makeUpdatedUrl;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the current in browser Query String updated with the key values provided.
|
|
67
|
+
* If a value is undefined in the passed map it will be deleted from the Query String.
|
|
68
|
+
*/
|
|
69
|
+
private static _makeUpdatedQueryString;
|
|
70
|
+
/**
|
|
71
|
+
* @returns The current in browser Query String as a Map
|
|
72
|
+
*/
|
|
73
|
+
static currentQsKeyValues(): Map<string, string>;
|
|
74
|
+
/**
|
|
75
|
+
* If the passed currentState is a CfgIOContainer it will update it with the
|
|
76
|
+
* passed message. If not it will create a new CfgIOContainer with the message.
|
|
77
|
+
*/
|
|
78
|
+
private static _makeUpdatedState;
|
|
79
|
+
protected readonly eventType = "popstate";
|
|
80
|
+
protected getDataFromEvent(event: PopStateEvent): unknown;
|
|
81
|
+
static getMessageFromCurrentHistoryState(messageKey: string): unknown | undefined;
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
51
84
|
//# sourceMappingURL=CfgHistoryManager.d.ts.map
|