@configura/web-api 2.0.0-alpha.21 → 2.0.0-alpha.22
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 +622 -597
- package/dist/CatalogueAPI.js +329 -328
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +344 -328
- package/dist/CfgProduct.js +996 -934
- package/dist/CfgReferencePathHelper.d.ts +26 -26
- package/dist/CfgReferencePathHelper.js +26 -26
- package/dist/ConfigurationConverter.d.ts +17 -17
- package/dist/ConfigurationConverter.js +175 -175
- package/dist/index.d.ts +23 -23
- package/dist/index.js +23 -23
- 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 +64 -64
- package/dist/io/CfgIOProdConfConnector.js +149 -149
- 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 +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 -91
- 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 +193 -189
- package/dist/productConfiguration/CfgFeature.js +671 -658
- package/dist/productConfiguration/CfgOption.d.ts +156 -151
- package/dist/productConfiguration/CfgOption.js +439 -422
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +129 -129
- package/dist/productConfiguration/CfgProductConfiguration.js +340 -340
- 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 -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/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/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +114 -114
- package/package.json +3 -3
|
@@ -1,27 +1,27 @@
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
27
27
|
//# sourceMappingURL=CfgReferencePathHelper.d.ts.map
|
|
@@ -1,26 +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
|
-
* 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
|
+
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,18 +1,18 @@
|
|
|
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;
|
|
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;
|
|
18
18
|
//# sourceMappingURL=ConfigurationConverter.d.ts.map
|
|
@@ -1,175 +1,175 @@
|
|
|
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
|
-
};
|
|
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";
|