@configura/web-api 1.3.0-alpha.0 → 1.3.0-alpha.4
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/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +448 -448
- package/dist/CatalogueAPI.js +206 -206
- package/dist/CfgProduct.d.ts +116 -116
- package/dist/CfgProduct.js +588 -588
- package/dist/index.d.ts +15 -15
- package/dist/index.js +15 -15
- package/dist/material/CfgMaterialMapping.d.ts +7 -7
- package/dist/material/CfgMaterialMapping.js +176 -176
- 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 +134 -80
- package/dist/productConfiguration/CfgFeature.js +483 -451
- package/dist/productConfiguration/CfgOption.d.ts +112 -64
- package/dist/productConfiguration/CfgOption.js +293 -263
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +50 -50
- package/dist/productConfiguration/CfgProductConfiguration.js +198 -198
- package/dist/productConfiguration/filters.d.ts +7 -7
- package/dist/productConfiguration/filters.js +29 -29
- package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
- package/dist/productConfiguration/productParamsGenerator.js +51 -51
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +9 -9
- package/dist/productConfiguration/utilitiesProductConfiguration.js +61 -61
- package/dist/productLoader.d.ts +11 -11
- package/dist/productLoader.js +41 -41
- package/dist/tests/testData/collectorForTest.d.ts +73 -73
- package/dist/tests/testData/collectorForTest.js +195 -195
- package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
- package/dist/tests/testData/dummyProductForTest.js +35 -35
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +32 -32
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +368 -368
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +199 -199
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +189 -189
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1117 -1117
- package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +28 -28
- package/dist/tests/testData/testDataProductAggregatedPrice.js +205 -205
- package/dist/tests/testData/testDataUpcharge.d.ts +29 -29
- package/dist/tests/testData/testDataUpcharge.js +159 -159
- package/dist/utilitiesCatalogueData.d.ts +20 -18
- package/dist/utilitiesCatalogueData.js +64 -56
- package/dist/utilitiesCataloguePermission.d.ts +39 -39
- package/dist/utilitiesCataloguePermission.js +84 -84
- package/package.json +3 -3
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
export const groupAndSortCataloguePermissions = (cataloguePermissions) => {
|
|
2
|
-
const cataloguePermissionByEnterpriseKey = {};
|
|
3
|
-
cataloguePermissions
|
|
4
|
-
// Sort by enterprise
|
|
5
|
-
.sort((a, b) => a.enterprise.toLocaleLowerCase().localeCompare(b.enterprise.toLocaleLowerCase()))
|
|
6
|
-
.forEach((c) => {
|
|
7
|
-
const enterprise = c.enterprise.toLowerCase();
|
|
8
|
-
if (cataloguePermissionByEnterpriseKey[enterprise] === undefined) {
|
|
9
|
-
cataloguePermissionByEnterpriseKey[enterprise] = [];
|
|
10
|
-
}
|
|
11
|
-
cataloguePermissionByEnterpriseKey[enterprise].push(c);
|
|
12
|
-
});
|
|
13
|
-
// Sort by prdcat
|
|
14
|
-
Object.keys(cataloguePermissionByEnterpriseKey).forEach((enterprise) => cataloguePermissionByEnterpriseKey[enterprise].sort((a, b) => a.prdCat.toLocaleLowerCase().localeCompare(b.prdCat.toLocaleLowerCase())));
|
|
15
|
-
return cataloguePermissionByEnterpriseKey;
|
|
16
|
-
};
|
|
17
|
-
export const isParamSet = (param) => param !== "" && param !== "-";
|
|
18
|
-
export const createCataloguePermissionsFilter = (enterprise, prdCat, prdCatVersion, priceList, vendor) => {
|
|
19
|
-
return (perm) => (!isParamSet(enterprise) || enterprise === perm.enterprise) &&
|
|
20
|
-
(!isParamSet(prdCat) || prdCat === perm.prdCat) &&
|
|
21
|
-
(!isParamSet(prdCatVersion) || prdCatVersion === perm.prdCatVersion) &&
|
|
22
|
-
(!isParamSet(vendor) ||
|
|
23
|
-
perm.vendors === undefined ||
|
|
24
|
-
perm.vendors.some((v) => vendor === v)) &&
|
|
25
|
-
(!isParamSet(priceList) ||
|
|
26
|
-
perm.priceLists === undefined ||
|
|
27
|
-
perm.priceLists.some((p) => priceList === p));
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Sometimes you will want to use the latest available prdCatVersion. This method will
|
|
31
|
-
* find the highest prdCatVersion version in the cataloguePermissions. If the versions are
|
|
32
|
-
* numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
|
|
33
|
-
* string compare.
|
|
34
|
-
* @param cataloguePermissions
|
|
35
|
-
* @param enterprise
|
|
36
|
-
* @param prdCat
|
|
37
|
-
* @param priceList
|
|
38
|
-
* @param vendor
|
|
39
|
-
*/
|
|
40
|
-
export const getPrdCatVersionFromPermissions = (cataloguePermissions, enterprise, prdCat, priceList, vendor) => {
|
|
41
|
-
const filter = createCataloguePermissionsFilter(enterprise, prdCat, "-", priceList, vendor);
|
|
42
|
-
const applicablePermissions = cataloguePermissions.filter(filter);
|
|
43
|
-
return applicablePermissions.reduce((pVersion, c) => {
|
|
44
|
-
const cVersion = c.prdCatVersion;
|
|
45
|
-
if (pVersion === undefined) {
|
|
46
|
-
return cVersion;
|
|
47
|
-
}
|
|
48
|
-
const pNum = parseFloat(pVersion);
|
|
49
|
-
const cNum = parseFloat(cVersion);
|
|
50
|
-
if (isNaN(pNum) || isNaN(cNum)) {
|
|
51
|
-
return pVersion < cVersion ? cVersion : pVersion;
|
|
52
|
-
}
|
|
53
|
-
return pNum < cNum ? cVersion : pVersion;
|
|
54
|
-
}, undefined);
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
|
|
58
|
-
* This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
|
|
59
|
-
* permissions. If it fails to find any applicable permissions the original value is returned.
|
|
60
|
-
* @param auth
|
|
61
|
-
* @param params
|
|
62
|
-
*/
|
|
63
|
-
export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermissions) => {
|
|
64
|
-
const { enterprise, prdCat, prdCatVersion, priceList, vendor } = params;
|
|
65
|
-
if (isParamSet(prdCatVersion)) {
|
|
66
|
-
return prdCatVersion;
|
|
67
|
-
}
|
|
68
|
-
const highestFoundVersion = getPrdCatVersionFromPermissions(cataloguePermissions, enterprise, prdCat, priceList, vendor);
|
|
69
|
-
if (highestFoundVersion === undefined) {
|
|
70
|
-
return prdCatVersion;
|
|
71
|
-
}
|
|
72
|
-
return highestFoundVersion;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
|
|
76
|
-
* This method will, if the prdCatVersion is not set, fetch the highest available from the
|
|
77
|
-
* cataloguePermissions and insert it into a copy of the original params. If it fails to find any
|
|
78
|
-
* applicable auth-permissions the original value is returned.
|
|
79
|
-
* @param auth
|
|
80
|
-
* @param params
|
|
81
|
-
*/
|
|
82
|
-
export const fillMissingPrdCatVersionFromPermissions = (params, cataloguePermissions) => {
|
|
83
|
-
return Object.assign(Object.assign({}, params), { prdCatVersion: getPrdCatVersionOrLatestFromPermissions(params, cataloguePermissions) });
|
|
84
|
-
};
|
|
1
|
+
export const groupAndSortCataloguePermissions = (cataloguePermissions) => {
|
|
2
|
+
const cataloguePermissionByEnterpriseKey = {};
|
|
3
|
+
cataloguePermissions
|
|
4
|
+
// Sort by enterprise
|
|
5
|
+
.sort((a, b) => a.enterprise.toLocaleLowerCase().localeCompare(b.enterprise.toLocaleLowerCase()))
|
|
6
|
+
.forEach((c) => {
|
|
7
|
+
const enterprise = c.enterprise.toLowerCase();
|
|
8
|
+
if (cataloguePermissionByEnterpriseKey[enterprise] === undefined) {
|
|
9
|
+
cataloguePermissionByEnterpriseKey[enterprise] = [];
|
|
10
|
+
}
|
|
11
|
+
cataloguePermissionByEnterpriseKey[enterprise].push(c);
|
|
12
|
+
});
|
|
13
|
+
// Sort by prdcat
|
|
14
|
+
Object.keys(cataloguePermissionByEnterpriseKey).forEach((enterprise) => cataloguePermissionByEnterpriseKey[enterprise].sort((a, b) => a.prdCat.toLocaleLowerCase().localeCompare(b.prdCat.toLocaleLowerCase())));
|
|
15
|
+
return cataloguePermissionByEnterpriseKey;
|
|
16
|
+
};
|
|
17
|
+
export const isParamSet = (param) => param !== "" && param !== "-";
|
|
18
|
+
export const createCataloguePermissionsFilter = (enterprise, prdCat, prdCatVersion, priceList, vendor) => {
|
|
19
|
+
return (perm) => (!isParamSet(enterprise) || enterprise === perm.enterprise) &&
|
|
20
|
+
(!isParamSet(prdCat) || prdCat === perm.prdCat) &&
|
|
21
|
+
(!isParamSet(prdCatVersion) || prdCatVersion === perm.prdCatVersion) &&
|
|
22
|
+
(!isParamSet(vendor) ||
|
|
23
|
+
perm.vendors === undefined ||
|
|
24
|
+
perm.vendors.some((v) => vendor === v)) &&
|
|
25
|
+
(!isParamSet(priceList) ||
|
|
26
|
+
perm.priceLists === undefined ||
|
|
27
|
+
perm.priceLists.some((p) => priceList === p));
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Sometimes you will want to use the latest available prdCatVersion. This method will
|
|
31
|
+
* find the highest prdCatVersion version in the cataloguePermissions. If the versions are
|
|
32
|
+
* numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
|
|
33
|
+
* string compare.
|
|
34
|
+
* @param cataloguePermissions
|
|
35
|
+
* @param enterprise
|
|
36
|
+
* @param prdCat
|
|
37
|
+
* @param priceList
|
|
38
|
+
* @param vendor
|
|
39
|
+
*/
|
|
40
|
+
export const getPrdCatVersionFromPermissions = (cataloguePermissions, enterprise, prdCat, priceList, vendor) => {
|
|
41
|
+
const filter = createCataloguePermissionsFilter(enterprise, prdCat, "-", priceList, vendor);
|
|
42
|
+
const applicablePermissions = cataloguePermissions.filter(filter);
|
|
43
|
+
return applicablePermissions.reduce((pVersion, c) => {
|
|
44
|
+
const cVersion = c.prdCatVersion;
|
|
45
|
+
if (pVersion === undefined) {
|
|
46
|
+
return cVersion;
|
|
47
|
+
}
|
|
48
|
+
const pNum = parseFloat(pVersion);
|
|
49
|
+
const cNum = parseFloat(cVersion);
|
|
50
|
+
if (isNaN(pNum) || isNaN(cNum)) {
|
|
51
|
+
return pVersion < cVersion ? cVersion : pVersion;
|
|
52
|
+
}
|
|
53
|
+
return pNum < cNum ? cVersion : pVersion;
|
|
54
|
+
}, undefined);
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
|
|
58
|
+
* This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
|
|
59
|
+
* permissions. If it fails to find any applicable permissions the original value is returned.
|
|
60
|
+
* @param auth
|
|
61
|
+
* @param params
|
|
62
|
+
*/
|
|
63
|
+
export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermissions) => {
|
|
64
|
+
const { enterprise, prdCat, prdCatVersion, priceList, vendor } = params;
|
|
65
|
+
if (isParamSet(prdCatVersion)) {
|
|
66
|
+
return prdCatVersion;
|
|
67
|
+
}
|
|
68
|
+
const highestFoundVersion = getPrdCatVersionFromPermissions(cataloguePermissions, enterprise, prdCat, priceList, vendor);
|
|
69
|
+
if (highestFoundVersion === undefined) {
|
|
70
|
+
return prdCatVersion;
|
|
71
|
+
}
|
|
72
|
+
return highestFoundVersion;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
|
|
76
|
+
* This method will, if the prdCatVersion is not set, fetch the highest available from the
|
|
77
|
+
* cataloguePermissions and insert it into a copy of the original params. If it fails to find any
|
|
78
|
+
* applicable auth-permissions the original value is returned.
|
|
79
|
+
* @param auth
|
|
80
|
+
* @param params
|
|
81
|
+
*/
|
|
82
|
+
export const fillMissingPrdCatVersionFromPermissions = (params, cataloguePermissions) => {
|
|
83
|
+
return Object.assign(Object.assign({}, params), { prdCatVersion: getPrdCatVersionOrLatestFromPermissions(params, cataloguePermissions) });
|
|
84
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/web-api",
|
|
3
|
-
"version": "1.3.0-alpha.
|
|
3
|
+
"version": "1.3.0-alpha.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@configura/web-utilities": "^1.3.0-alpha.
|
|
26
|
+
"@configura/web-utilities": "^1.3.0-alpha.4"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "c15fa8640b1de9daf3374aacc82f29ccc6b4d91a"
|
|
29
29
|
}
|