@configura/web-api 1.6.0-iotest.4 → 1.6.0-rc.0

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 (92) hide show
  1. package/.eslintrc.json +18 -0
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/CatalogueAPI.d.ts +507 -511
  5. package/dist/CatalogueAPI.js +280 -273
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +253 -240
  9. package/dist/CfgProduct.js +733 -668
  10. package/dist/index.d.ts +20 -24
  11. package/dist/index.js +20 -24
  12. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  13. package/dist/material/CfgMaterialMapping.js +181 -181
  14. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  15. package/dist/material/CfgMtrlApplication.js +43 -43
  16. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  17. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  18. package/dist/material/CfgMtrlSource.d.ts +19 -19
  19. package/dist/material/CfgMtrlSource.js +40 -40
  20. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  21. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  22. package/dist/productConfiguration/CfgFeature.d.ts +188 -178
  23. package/dist/productConfiguration/CfgFeature.js +636 -611
  24. package/dist/productConfiguration/CfgOption.d.ts +150 -128
  25. package/dist/productConfiguration/CfgOption.js +426 -394
  26. package/dist/productConfiguration/CfgProductConfiguration.d.ts +120 -121
  27. package/dist/productConfiguration/CfgProductConfiguration.js +309 -306
  28. package/dist/productConfiguration/filters.d.ts +15 -15
  29. package/dist/productConfiguration/filters.js +70 -67
  30. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  31. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  32. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
  33. package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -80
  34. package/dist/productLoader.d.ts +33 -33
  35. package/dist/productLoader.js +49 -49
  36. package/dist/syncGroups/SyncGroupsApplyMode.d.ts +21 -0
  37. package/dist/syncGroups/SyncGroupsApplyMode.js +21 -0
  38. package/dist/syncGroups/SyncGroupsHandler.d.ts +36 -0
  39. package/dist/syncGroups/SyncGroupsHandler.js +349 -0
  40. package/dist/syncGroups/SyncGroupsPathHelper.d.ts +27 -0
  41. package/dist/syncGroups/SyncGroupsPathHelper.js +90 -0
  42. package/dist/syncGroups/SyncGroupsState.d.ts +26 -0
  43. package/dist/syncGroups/SyncGroupsState.js +113 -0
  44. package/dist/syncGroups/SyncGroupsTransaction.d.ts +155 -0
  45. package/dist/syncGroups/SyncGroupsTransaction.js +576 -0
  46. package/dist/tasks/TaskHandler.d.ts +78 -78
  47. package/dist/tasks/TaskHandler.js +276 -265
  48. package/dist/tasks/formats.d.ts +4 -4
  49. package/dist/tasks/formats.js +7 -7
  50. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  51. package/dist/tests/testData/collectorForTest.js +194 -195
  52. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  53. package/dist/tests/testData/dummyProductForTest.js +36 -36
  54. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -32
  55. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +277 -348
  56. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  57. package/dist/tests/testData/testDataCachedGetProduct.js +185 -196
  58. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  59. package/dist/tests/testData/testDataCachedPostValidate.js +183 -183
  60. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  61. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
  62. package/dist/tests/testData/testDataOptions.d.ts +13 -0
  63. package/dist/tests/testData/testDataOptions.js +60 -0
  64. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
  65. package/dist/tests/testData/testDataProductAggregatedPrice.js +187 -198
  66. package/dist/tests/testData/testDataUpcharge.d.ts +8 -29
  67. package/dist/tests/testData/testDataUpcharge.js +119 -151
  68. package/dist/utilitiesCatalogueData.d.ts +31 -25
  69. package/dist/utilitiesCatalogueData.js +162 -65
  70. package/dist/utilitiesCataloguePermission.d.ts +37 -39
  71. package/dist/utilitiesCataloguePermission.js +80 -84
  72. package/dist/utilitiesNumericValues.d.ts +24 -24
  73. package/dist/utilitiesNumericValues.js +109 -109
  74. package/package.json +3 -3
  75. package/dist/io/CfgHistoryManager.d.ts +0 -26
  76. package/dist/io/CfgHistoryManager.js +0 -58
  77. package/dist/io/CfgHistoryToCameraConfConnector.d.ts +0 -15
  78. package/dist/io/CfgHistoryToCameraConfConnector.js +0 -58
  79. package/dist/io/CfgHistoryToProdConfConnector.d.ts +0 -14
  80. package/dist/io/CfgHistoryToProdConfConnector.js +0 -24
  81. package/dist/io/CfgIOCameraConfConnector.d.ts +0 -31
  82. package/dist/io/CfgIOCameraConfConnector.js +0 -72
  83. package/dist/io/CfgIOManager.d.ts +0 -29
  84. package/dist/io/CfgIOManager.js +0 -89
  85. package/dist/io/CfgIOProdConfConnector.d.ts +0 -36
  86. package/dist/io/CfgIOProdConfConnector.js +0 -102
  87. package/dist/io/CfgWindowMessageManager.d.ts +0 -13
  88. package/dist/io/CfgWindowMessageManager.js +0 -33
  89. package/dist/io/CfgWindowMessageToCameraConfConnector.d.ts +0 -6
  90. package/dist/io/CfgWindowMessageToCameraConfConnector.js +0 -6
  91. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +0 -14
  92. package/dist/io/CfgWindowMessageToProdConfConnector.js +0 -17
@@ -1,84 +1,80 @@
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) => (perm) => (!isParamSet(enterprise) || enterprise === perm.enterprise) &&
19
+ (!isParamSet(prdCat) || prdCat === perm.prdCat) &&
20
+ (!isParamSet(prdCatVersion) || prdCatVersion === perm.prdCatVersion) &&
21
+ (!isParamSet(vendor) ||
22
+ perm.vendors === undefined ||
23
+ perm.vendors.some((v) => vendor === v)) &&
24
+ (!isParamSet(priceList) ||
25
+ perm.priceLists === undefined ||
26
+ perm.priceLists.some((p) => priceList === p));
27
+ /**
28
+ * Sometimes you will want to use the latest available prdCatVersion. This method will
29
+ * find the highest prdCatVersion version in the cataloguePermissions. If the versions are
30
+ * numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
31
+ * string compare.
32
+ * @param cataloguePermissions
33
+ * @param enterprise
34
+ * @param prdCat
35
+ * @param priceList
36
+ * @param vendor
37
+ */
38
+ export const getPrdCatVersionFromPermissions = (cataloguePermissions, enterprise, prdCat, priceList, vendor) => {
39
+ const filter = createCataloguePermissionsFilter(enterprise, prdCat, "-", priceList, vendor);
40
+ const applicablePermissions = cataloguePermissions.filter(filter);
41
+ return applicablePermissions.reduce((pVersion, c) => {
42
+ const cVersion = c.prdCatVersion;
43
+ if (pVersion === undefined) {
44
+ return cVersion;
45
+ }
46
+ const pNum = parseFloat(pVersion);
47
+ const cNum = parseFloat(cVersion);
48
+ if (isNaN(pNum) || isNaN(cNum)) {
49
+ return pVersion < cVersion ? cVersion : pVersion;
50
+ }
51
+ return pNum < cNum ? cVersion : pVersion;
52
+ }, undefined);
53
+ };
54
+ /**
55
+ * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
56
+ * This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
57
+ * permissions. If it fails to find any applicable permissions the original value is returned.
58
+ * @param auth
59
+ * @param params
60
+ */
61
+ export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermissions) => {
62
+ const { enterprise, prdCat, prdCatVersion, priceList, vendor } = params;
63
+ if (isParamSet(prdCatVersion)) {
64
+ return prdCatVersion;
65
+ }
66
+ const highestFoundVersion = getPrdCatVersionFromPermissions(cataloguePermissions, enterprise, prdCat, priceList, vendor);
67
+ if (highestFoundVersion === undefined) {
68
+ return prdCatVersion;
69
+ }
70
+ return highestFoundVersion;
71
+ };
72
+ /**
73
+ * Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
74
+ * This method will, if the prdCatVersion is not set, fetch the highest available from the
75
+ * cataloguePermissions and insert it into a copy of the original params. If it fails to find any
76
+ * applicable auth-permissions the original value is returned.
77
+ * @param auth
78
+ * @param params
79
+ */
80
+ export const fillMissingPrdCatVersionFromPermissions = (params, cataloguePermissions) => (Object.assign(Object.assign({}, params), { prdCatVersion: getPrdCatVersionOrLatestFromPermissions(params, cataloguePermissions) }));
@@ -1,25 +1,25 @@
1
- import { CodeRange } from "./CatalogueAPI.js";
2
- export declare class NumericValuesSelection {
3
- constructor(rawRanges: CodeRange[]);
4
- readonly ranges: (NumericValueRangeDefinition | NumericValueDiscrete)[];
5
- includesValue(value: number): boolean;
6
- get first(): number;
7
- get legend(): string;
8
- }
9
- export declare class NumericValueDiscrete {
10
- readonly value: number;
11
- constructor(value: number);
12
- includesValue(value: number): boolean;
13
- get first(): number;
14
- get legend(): string;
15
- }
16
- export declare class NumericValueRangeDefinition {
17
- constructor(rawRange: CodeRange);
18
- readonly minValue: number;
19
- readonly maxValue: number;
20
- readonly increment: number | undefined;
21
- includesValue(value: number): boolean;
22
- get first(): number;
23
- get legend(): string;
24
- }
1
+ import { CodeRange } from "./CatalogueAPI.js";
2
+ export declare class NumericValuesSelection {
3
+ constructor(rawRanges: CodeRange[]);
4
+ readonly ranges: (NumericValueRangeDefinition | NumericValueDiscrete)[];
5
+ includesValue(value: number): boolean;
6
+ get first(): number;
7
+ get legend(): string;
8
+ }
9
+ export declare class NumericValueDiscrete {
10
+ readonly value: number;
11
+ constructor(value: number);
12
+ includesValue(value: number): boolean;
13
+ get first(): number;
14
+ get legend(): string;
15
+ }
16
+ export declare class NumericValueRangeDefinition {
17
+ constructor(rawRange: CodeRange);
18
+ readonly minValue: number;
19
+ readonly maxValue: number;
20
+ readonly increment: number | undefined;
21
+ includesValue(value: number): boolean;
22
+ get first(): number;
23
+ get legend(): string;
24
+ }
25
25
  //# sourceMappingURL=utilitiesNumericValues.d.ts.map
@@ -1,109 +1,109 @@
1
- /** Rounds the supplied value to 3 decimal points. */
2
- function round(v) {
3
- return Math.round(v * 1000) / 1000;
4
- }
5
- export class NumericValuesSelection {
6
- constructor(rawRanges) {
7
- if (rawRanges.length === 0) {
8
- throw new Error("A numeric values selection must have at least one value");
9
- }
10
- this.ranges = rawRanges.map((rawRange) => {
11
- const { minValue, maxValue } = rawRange;
12
- if (minValue === maxValue) {
13
- return new NumericValueDiscrete(minValue);
14
- }
15
- else {
16
- return new NumericValueRangeDefinition(rawRange);
17
- }
18
- });
19
- }
20
- includesValue(value) {
21
- return this.ranges.some((range) => range.includesValue(value));
22
- }
23
- get first() {
24
- return this.ranges[0].first;
25
- }
26
- get legend() {
27
- return this.ranges
28
- .sort((l, r) => l.first - r.first)
29
- .map((range) => range.legend)
30
- .join(", ");
31
- }
32
- }
33
- export class NumericValueDiscrete {
34
- constructor(value) {
35
- this.value = value;
36
- }
37
- includesValue(value) {
38
- return value === this.value;
39
- }
40
- get first() {
41
- return this.value;
42
- }
43
- get legend() {
44
- return `${round(this.value)}`;
45
- }
46
- }
47
- export class NumericValueRangeDefinition {
48
- constructor(rawRange) {
49
- const { minValue, maxValue, increment } = rawRange;
50
- this.minValue = minValue;
51
- this.maxValue = maxValue;
52
- this.increment = increment === 0 ? undefined : increment;
53
- }
54
- includesValue(value) {
55
- const { minValue: start, maxValue: end, increment: step } = this;
56
- if (value < start || end < value) {
57
- return false;
58
- }
59
- // TODO: This comparison will often fail due to the fact that all the values used are
60
- // base-2 (binary) floating point numbers based on base-10 (decimal) input strings.
61
- //
62
- // Such calculations are often not 100% accurate as is visible in JS by simply
63
- // computing "0.1 + 0.2" which should equal about "0.30000000000000004" != "0.3".
64
- //
65
- // The easiest workaround is to define an static accuracy, say "6 decimals" and round
66
- // everything when comparing. One could also use a scaled version of Number.EPSILON to
67
- // dynamically match the precision to the precision of the input numbers.
68
- //
69
- // Both workarounds share the same problem however; an infinite number of numbers will be
70
- // included in the range since an "infinite" number of values will map to the same rounded
71
- // actual number.
72
- //
73
- // The proper fix is probably to use a fixed point mathematics, where we either define a
74
- // maximum of say 6 decimals or the number of decimals vary on the number of decimals given
75
- // in the JSON for each value.
76
- //
77
- // This should work given that the input in CatCreator is decimal (human created string) and
78
- // both XML and JSON uses string based decimal numbers. One question mark remains however,
79
- // and that is how the numbers are stored in CatCreator if you use a db3-file. If it is a
80
- // string there as well, everything is dandy. Otherwise we might get problems with rounding
81
- // or infinite decimals during the conversions to/from the db3-file.
82
- return step === undefined || (value - start) % step === 0;
83
- }
84
- get first() {
85
- return this.minValue;
86
- }
87
- get legend() {
88
- const { minValue, maxValue, increment } = this;
89
- if (increment === undefined) {
90
- return `[${round(minValue)} ... ${round(maxValue)}]`;
91
- }
92
- const steps = 1 + Math.floor((maxValue - minValue) / increment);
93
- let legend = `[${round(minValue)}`;
94
- if (increment !== undefined && 3 <= steps) {
95
- legend += `, ${round(minValue + increment)}`;
96
- }
97
- if (5 <= steps) {
98
- legend += " ... ";
99
- }
100
- else {
101
- legend += ", ";
102
- }
103
- if (4 <= steps) {
104
- legend += `${round(minValue + increment * (steps - 2))}, `;
105
- }
106
- legend += `${round(minValue + increment * (steps - 1))}]`;
107
- return legend;
108
- }
109
- }
1
+ /** Rounds the supplied value to 3 decimal points. */
2
+ function round(v) {
3
+ return Math.round(v * 1000) / 1000;
4
+ }
5
+ export class NumericValuesSelection {
6
+ constructor(rawRanges) {
7
+ if (rawRanges.length === 0) {
8
+ throw new Error("A numeric values selection must have at least one value");
9
+ }
10
+ this.ranges = rawRanges.map((rawRange) => {
11
+ const { minValue, maxValue } = rawRange;
12
+ if (minValue === maxValue) {
13
+ return new NumericValueDiscrete(minValue);
14
+ }
15
+ else {
16
+ return new NumericValueRangeDefinition(rawRange);
17
+ }
18
+ });
19
+ }
20
+ includesValue(value) {
21
+ return this.ranges.some((range) => range.includesValue(value));
22
+ }
23
+ get first() {
24
+ return this.ranges[0].first;
25
+ }
26
+ get legend() {
27
+ return this.ranges
28
+ .sort((l, r) => l.first - r.first)
29
+ .map((range) => range.legend)
30
+ .join(", ");
31
+ }
32
+ }
33
+ export class NumericValueDiscrete {
34
+ constructor(value) {
35
+ this.value = value;
36
+ }
37
+ includesValue(value) {
38
+ return value === this.value;
39
+ }
40
+ get first() {
41
+ return this.value;
42
+ }
43
+ get legend() {
44
+ return `${round(this.value)}`;
45
+ }
46
+ }
47
+ export class NumericValueRangeDefinition {
48
+ constructor(rawRange) {
49
+ const { minValue, maxValue, increment } = rawRange;
50
+ this.minValue = minValue;
51
+ this.maxValue = maxValue;
52
+ this.increment = increment === 0 ? undefined : increment;
53
+ }
54
+ includesValue(value) {
55
+ const { minValue: start, maxValue: end, increment: step } = this;
56
+ if (value < start || end < value) {
57
+ return false;
58
+ }
59
+ // TODO: This comparison will often fail due to the fact that all the values used are
60
+ // base-2 (binary) floating point numbers based on base-10 (decimal) input strings.
61
+ //
62
+ // Such calculations are often not 100% accurate as is visible in JS by simply
63
+ // computing "0.1 + 0.2" which should equal about "0.30000000000000004" != "0.3".
64
+ //
65
+ // The easiest workaround is to define an static accuracy, say "6 decimals" and round
66
+ // everything when comparing. One could also use a scaled version of Number.EPSILON to
67
+ // dynamically match the precision to the precision of the input numbers.
68
+ //
69
+ // Both workarounds share the same problem however; an infinite number of numbers will be
70
+ // included in the range since an "infinite" number of values will map to the same rounded
71
+ // actual number.
72
+ //
73
+ // The proper fix is probably to use a fixed point mathematics, where we either define a
74
+ // maximum of say 6 decimals or the number of decimals vary on the number of decimals given
75
+ // in the JSON for each value.
76
+ //
77
+ // This should work given that the input in CatCreator is decimal (human created string) and
78
+ // both XML and JSON uses string based decimal numbers. One question mark remains however,
79
+ // and that is how the numbers are stored in CatCreator if you use a db3-file. If it is a
80
+ // string there as well, everything is dandy. Otherwise we might get problems with rounding
81
+ // or infinite decimals during the conversions to/from the db3-file.
82
+ return step === undefined || (value - start) % step === 0;
83
+ }
84
+ get first() {
85
+ return this.minValue;
86
+ }
87
+ get legend() {
88
+ const { minValue, maxValue, increment } = this;
89
+ if (increment === undefined) {
90
+ return `[${round(minValue)} ... ${round(maxValue)}]`;
91
+ }
92
+ const steps = 1 + Math.floor((maxValue - minValue) / increment);
93
+ let legend = `[${round(minValue)}`;
94
+ if (increment !== undefined && 3 <= steps) {
95
+ legend += `, ${round(minValue + increment)}`;
96
+ }
97
+ if (5 <= steps) {
98
+ legend += " ... ";
99
+ }
100
+ else {
101
+ legend += ", ";
102
+ }
103
+ if (4 <= steps) {
104
+ legend += `${round(minValue + increment * (steps - 2))}, `;
105
+ }
106
+ legend += `${round(minValue + increment * (steps - 1))}]`;
107
+ return legend;
108
+ }
109
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "1.6.0-iotest.4",
3
+ "version": "1.6.0-rc.0",
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.6.0-iotest.4"
26
+ "@configura/web-utilities": "1.6.0-rc.0"
27
27
  },
28
- "gitHead": "d6eb7775e09c974d24dc5f44c97a26d4d42c3c68"
28
+ "gitHead": "0c932a04b2ef1dd3c5547adc8e4b0737aa78248a"
29
29
  }
@@ -1,26 +0,0 @@
1
- import { CfgIOManager } from "./CfgIOManager.js";
2
- export declare type CfgHistoryManagerSendData<D> = {
3
- message: D;
4
- useHistoryPush: boolean;
5
- qsKeyValues: Map<string, string | undefined> | undefined;
6
- };
7
- /**
8
- * Instantiating the class will use the history api to update your
9
- * url with configuration changes
10
- * Only handles configuration, not product
11
- */
12
- export declare class CfgHistoryManager<D extends {
13
- initial: boolean;
14
- }> extends CfgIOManager<"popstate", CfgHistoryManagerSendData<D>> {
15
- protected doSend(messageKey: string, data: CfgHistoryManagerSendData<D>): void;
16
- private static _makeUpdatedUrl;
17
- private static _makeUpdatedQueryString;
18
- /**
19
- * @returns The current query string as a Map
20
- */
21
- static currentQsKeyValues(): Map<string, string>;
22
- private static _makeUpdatedState;
23
- protected readonly eventType = "popstate";
24
- protected getDataFromEvent(event: PopStateEvent): unknown;
25
- }
26
- //# sourceMappingURL=CfgHistoryManager.d.ts.map
@@ -1,58 +0,0 @@
1
- import { mapQueryString, unmapQueryString } from "@configura/web-utilities";
2
- import { CfgIOManager } from "./CfgIOManager.js";
3
- /**
4
- * Instantiating the class will use the history api to update your
5
- * url with configuration changes
6
- * Only handles configuration, not product
7
- */
8
- export class CfgHistoryManager extends CfgIOManager {
9
- constructor() {
10
- super(...arguments);
11
- this.eventType = "popstate";
12
- }
13
- doSend(messageKey, data) {
14
- const { qsKeyValues, message, useHistoryPush } = data;
15
- const newUrl = qsKeyValues === undefined ? null : CfgHistoryManager._makeUpdatedUrl(qsKeyValues);
16
- const newState = CfgHistoryManager._makeUpdatedState(message, messageKey);
17
- if (!message.initial && useHistoryPush) {
18
- window.history.pushState(newState, "", newUrl);
19
- }
20
- else {
21
- window.history.replaceState(newState, "", newUrl);
22
- }
23
- }
24
- static _makeUpdatedUrl(qsKeyValues) {
25
- const qs = this._makeUpdatedQueryString(qsKeyValues);
26
- return `${window.location.origin}${window.location.pathname}${qs ? "?" : ""}${qs}${window.location.hash}`;
27
- }
28
- static _makeUpdatedQueryString(qsKeyValues) {
29
- const currentKeyValues = this.currentQsKeyValues();
30
- for (const [key, value] of qsKeyValues) {
31
- if (value === undefined) {
32
- currentKeyValues.delete(key);
33
- }
34
- else {
35
- currentKeyValues.set(key, value);
36
- }
37
- }
38
- return unmapQueryString(currentKeyValues);
39
- }
40
- /**
41
- * @returns The current query string as a Map
42
- */
43
- static currentQsKeyValues() {
44
- return mapQueryString(window.location.search);
45
- }
46
- static _makeUpdatedState(message, messageKey) {
47
- let messages = {};
48
- const currentState = window.history.state;
49
- if (CfgIOManager.isIOContainer(currentState)) {
50
- messages = currentState.messages;
51
- }
52
- messages[messageKey] = message;
53
- return CfgIOManager.makeContainer(messages);
54
- }
55
- getDataFromEvent(event) {
56
- return event.state;
57
- }
58
- }
@@ -1,15 +0,0 @@
1
- import { Observable } from "@configura/web-utilities";
2
- import { CfgHistoryManager, CfgHistoryManagerSendData } from "./CfgHistoryManager.js";
3
- import { CfgCameraConf, CfgCameraConfMessage, CfgIOCameraConfConnector } from "./CfgIOCameraConfConnector.js";
4
- export declare class CfgHistoryToCameraConfConnector extends CfgIOCameraConfConnector<"popstate", CfgHistoryManagerSendData<CfgCameraConfMessage>, CfgHistoryManager<CfgCameraConfMessage>> {
5
- private readonly defaults;
6
- private readonly _qsKeyYaw;
7
- private readonly _qsKeyPitch;
8
- static make(manager: CfgHistoryManager<CfgCameraConfMessage>, defaults: CfgCameraConf, cameraControl: Observable<CfgCameraConf>, qsKeyYaw?: string, qsKeyPitch?: string): {
9
- instance: CfgHistoryToCameraConfConnector;
10
- initial: CfgCameraConf;
11
- };
12
- private constructor();
13
- protected makeSendData(cameraConf: CfgCameraConf, initial: boolean): CfgHistoryManagerSendData<CfgCameraConfMessage>;
14
- }
15
- //# sourceMappingURL=CfgHistoryToCameraConfConnector.d.ts.map
@@ -1,58 +0,0 @@
1
- import { degToRad, radToDeg } from "@configura/web-utilities";
2
- import { CfgHistoryManager } from "./CfgHistoryManager.js";
3
- import { CfgIOCameraConfConnector, } from "./CfgIOCameraConfConnector.js";
4
- const YAW_QS_KEY = "stageyaw";
5
- const PITCH_QS_KEY = "stagepitch";
6
- function qsAsNumber(qsMap, key) {
7
- const asString = qsMap.get(key);
8
- if (asString === undefined) {
9
- return undefined;
10
- }
11
- const asNumber = parseFloat(asString);
12
- if (!isFinite(asNumber)) {
13
- return undefined;
14
- }
15
- return degToRad(asNumber);
16
- }
17
- function addToMap(map, key, value) {
18
- if (value === undefined) {
19
- map.delete(key);
20
- }
21
- else {
22
- const timesHundredString = `${Math.round(100 * radToDeg(value))}`;
23
- const decimalPlace = timesHundredString.length - 2;
24
- map.set(key, `${timesHundredString.substring(0, decimalPlace)}.${timesHundredString.substring(decimalPlace)}`);
25
- }
26
- }
27
- export class CfgHistoryToCameraConfConnector extends CfgIOCameraConfConnector {
28
- constructor(manager, defaults, initial, cameraControl, _qsKeyYaw, _qsKeyPitch) {
29
- super(manager, initial, cameraControl);
30
- this.defaults = defaults;
31
- this._qsKeyYaw = _qsKeyYaw;
32
- this._qsKeyPitch = _qsKeyPitch;
33
- }
34
- static make(manager, defaults, cameraControl, qsKeyYaw = YAW_QS_KEY, qsKeyPitch = PITCH_QS_KEY) {
35
- var _a, _b;
36
- const qsKeyValues = CfgHistoryManager.currentQsKeyValues();
37
- const initial = {
38
- yaw: (_a = qsAsNumber(qsKeyValues, qsKeyYaw)) !== null && _a !== void 0 ? _a : defaults.yaw,
39
- pitch: (_b = qsAsNumber(qsKeyValues, qsKeyPitch)) !== null && _b !== void 0 ? _b : defaults.pitch,
40
- };
41
- const instance = new CfgHistoryToCameraConfConnector(manager, defaults, initial, cameraControl, qsKeyYaw, qsKeyPitch);
42
- return { instance, initial };
43
- }
44
- makeSendData(cameraConf, initial) {
45
- let qsKeyValues = undefined;
46
- if (!initial &&
47
- !(this.defaults.pitch === cameraConf.pitch && this.defaults.yaw === cameraConf.yaw)) {
48
- qsKeyValues = new Map();
49
- addToMap(qsKeyValues, this._qsKeyYaw, cameraConf.yaw);
50
- addToMap(qsKeyValues, this._qsKeyPitch, cameraConf.pitch);
51
- }
52
- return {
53
- message: this.makeMessage(cameraConf, initial),
54
- qsKeyValues,
55
- useHistoryPush: false,
56
- };
57
- }
58
- }
@@ -1,14 +0,0 @@
1
- import { AdditionalProductConfiguration } from "../CatalogueAPI.js";
2
- import { CfgHistoryManager, CfgHistoryManagerSendData } from "./CfgHistoryManager.js";
3
- import { CfgIOProdConfConnector, CfgProdConfMessage } from "./CfgIOProdConfConnector.js";
4
- export declare class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector<"popstate", CfgHistoryManagerSendData<CfgProdConfMessage>, CfgHistoryManager<CfgProdConfMessage>> {
5
- private readonly _useHistoryPush;
6
- private readonly _qsKey;
7
- /**
8
- * @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
9
- */
10
- constructor(manager: CfgHistoryManager<CfgProdConfMessage>, _useHistoryPush: boolean, _qsKey?: string, doValidate?: boolean);
11
- protected getInitialProdConf(): string | undefined;
12
- protected makeSendData(prodConf: AdditionalProductConfiguration, initial: boolean): CfgHistoryManagerSendData<CfgProdConfMessage>;
13
- }
14
- //# sourceMappingURL=CfgHistoryToProdConfConnector.d.ts.map