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