@configura/web-api 1.2.1 → 1.3.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +1 -1
  3. package/dist/CatalogueAPI.d.ts +448 -448
  4. package/dist/CatalogueAPI.js +206 -206
  5. package/dist/CfgProduct.d.ts +116 -116
  6. package/dist/CfgProduct.js +588 -588
  7. package/dist/index.d.ts +15 -15
  8. package/dist/index.js +15 -15
  9. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  10. package/dist/material/CfgMaterialMapping.js +176 -176
  11. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  12. package/dist/material/CfgMtrlApplication.js +43 -43
  13. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  14. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  15. package/dist/material/CfgMtrlSource.d.ts +19 -19
  16. package/dist/material/CfgMtrlSource.js +40 -40
  17. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  18. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  19. package/dist/productConfiguration/CfgFeature.d.ts +134 -134
  20. package/dist/productConfiguration/CfgFeature.js +483 -483
  21. package/dist/productConfiguration/CfgOption.d.ts +112 -112
  22. package/dist/productConfiguration/CfgOption.js +293 -293
  23. package/dist/productConfiguration/CfgProductConfiguration.d.ts +50 -50
  24. package/dist/productConfiguration/CfgProductConfiguration.js +198 -198
  25. package/dist/productConfiguration/filters.d.ts +7 -7
  26. package/dist/productConfiguration/filters.js +29 -29
  27. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  28. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  29. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +9 -9
  30. package/dist/productConfiguration/utilitiesProductConfiguration.js +61 -61
  31. package/dist/productLoader.d.ts +11 -11
  32. package/dist/productLoader.js +41 -41
  33. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  34. package/dist/tests/testData/collectorForTest.js +195 -195
  35. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  36. package/dist/tests/testData/dummyProductForTest.js +35 -35
  37. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +32 -32
  38. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +368 -368
  39. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  40. package/dist/tests/testData/testDataCachedGetProduct.js +199 -199
  41. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  42. package/dist/tests/testData/testDataCachedPostValidate.js +189 -189
  43. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  44. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1117 -1117
  45. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +28 -28
  46. package/dist/tests/testData/testDataProductAggregatedPrice.js +205 -205
  47. package/dist/tests/testData/testDataUpcharge.d.ts +29 -29
  48. package/dist/tests/testData/testDataUpcharge.js +159 -159
  49. package/dist/utilitiesCatalogueData.d.ts +20 -18
  50. package/dist/utilitiesCatalogueData.js +64 -56
  51. package/dist/utilitiesCataloguePermission.d.ts +39 -39
  52. package/dist/utilitiesCataloguePermission.js +84 -84
  53. 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.2.1",
3
+ "version": "1.3.0-alpha.3",
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.2.1"
26
+ "@configura/web-utilities": "^1.3.0-alpha.3"
27
27
  },
28
- "gitHead": "1750a720b149f9de7e12cc1a78714e029770e7fa"
28
+ "gitHead": "cf818cec9159a46e5254a1f001da6df7b663c62d"
29
29
  }