@configura/web-api 2.0.0-alpha.1 → 2.0.0-alpha.10
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/dist/CatalogueAPI.d.ts +27 -27
- package/dist/CatalogueAPI.js +4 -24
- package/dist/CfgProduct.d.ts +5 -5
- package/dist/CfgProduct.js +10 -8
- package/dist/CfgReferencePathHelper.d.ts +14 -1
- package/dist/CfgReferencePathHelper.js +14 -1
- package/dist/ConfigurationConverter.d.ts +4 -4
- package/dist/io/CfgHistoryManager.d.ts +4 -3
- package/dist/io/CfgHistoryManager.js +2 -2
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +5 -5
- package/dist/io/CfgHistoryToProdConfConnector.js +2 -2
- package/dist/io/CfgIOProdConfConnector.d.ts +15 -12
- package/dist/io/CfgIOProdConfConnector.js +27 -25
- package/dist/io/CfgObservableStateManager.d.ts +4 -0
- package/dist/io/CfgObservableStateManager.js +4 -0
- package/dist/io/CfgObservableStateToProdConfConnector.d.ts +4 -3
- package/dist/io/CfgObservableStateToProdConfConnector.js +4 -3
- package/dist/io/CfgWindowMessageManager.d.ts +2 -2
- package/dist/io/CfgWindowMessageManager.js +5 -2
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +4 -3
- package/dist/io/CfgWindowMessageToProdConfConnector.js +4 -3
- package/dist/productConfiguration/CfgFeature.d.ts +2 -2
- package/dist/productConfiguration/CfgOption.d.ts +2 -2
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +2 -2
- package/dist/productLoader.js +2 -2
- package/dist/utilitiesCatalogueData.d.ts +10 -1
- package/dist/utilitiesCatalogueData.js +10 -1
- package/dist/utilitiesCataloguePermission.d.ts +8 -2
- package/dist/utilitiesCataloguePermission.js +17 -14
- package/package.json +3 -3
package/dist/CatalogueAPI.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export interface DtoAdditionalProductConfiguration {
|
|
|
5
5
|
selOptions: Array<DtoSelectedOption>;
|
|
6
6
|
additionalProducts?: Array<DtoAdditionalProductConfiguration>;
|
|
7
7
|
}
|
|
8
|
+
/** AdditionalProductConfigurationV2 */
|
|
9
|
+
export interface DtoAdditionalProductConfigurationV2 extends DtoProductConfiguration {
|
|
10
|
+
refKey: string;
|
|
11
|
+
selected: boolean;
|
|
12
|
+
}
|
|
8
13
|
/** AdditionalProductRef */
|
|
9
14
|
export interface DtoAdditionalProductRef {
|
|
10
15
|
refKey: string;
|
|
@@ -22,7 +27,7 @@ export interface DtoApplicationArea {
|
|
|
22
27
|
material?: string;
|
|
23
28
|
preview?: string;
|
|
24
29
|
}
|
|
25
|
-
/**
|
|
30
|
+
/** ApplicationAreasResponse */
|
|
26
31
|
export interface DtoApplicationAreasResponse {
|
|
27
32
|
applicationAreas: Array<DtoApplicationArea>;
|
|
28
33
|
uuid: string;
|
|
@@ -74,31 +79,6 @@ export interface DtoCodeRange {
|
|
|
74
79
|
maxValue: number;
|
|
75
80
|
increment?: number;
|
|
76
81
|
}
|
|
77
|
-
/** ConfAddProd */
|
|
78
|
-
export interface DtoConfAddProd extends DtoConfProd {
|
|
79
|
-
refKey: string;
|
|
80
|
-
selected: boolean;
|
|
81
|
-
}
|
|
82
|
-
/** ConfFeature */
|
|
83
|
-
export interface DtoConfFeature {
|
|
84
|
-
code: string;
|
|
85
|
-
groupCode?: string;
|
|
86
|
-
unit?: string;
|
|
87
|
-
options?: Array<DtoConfOption>;
|
|
88
|
-
}
|
|
89
|
-
/** ConfOption */
|
|
90
|
-
export interface DtoConfOption {
|
|
91
|
-
code: string;
|
|
92
|
-
selected: boolean;
|
|
93
|
-
numericValue?: DtoValueWithUnit;
|
|
94
|
-
features?: Array<DtoConfFeature>;
|
|
95
|
-
}
|
|
96
|
-
/** ConfProd */
|
|
97
|
-
export interface DtoConfProd {
|
|
98
|
-
features?: Array<DtoConfFeature>;
|
|
99
|
-
additionalProducts?: Array<DtoConfAddProd>;
|
|
100
|
-
prodParams?: DtoProductParamsWithLang;
|
|
101
|
-
}
|
|
102
82
|
/** ErrorResponse */
|
|
103
83
|
export interface DtoErrorResponse {
|
|
104
84
|
error: string;
|
|
@@ -147,6 +127,13 @@ export interface DtoFeature {
|
|
|
147
127
|
syncGroup?: DtoSyncGroup;
|
|
148
128
|
unit?: string;
|
|
149
129
|
}
|
|
130
|
+
/** FeatureConfiguration */
|
|
131
|
+
export interface DtoFeatureConfiguration {
|
|
132
|
+
code: string;
|
|
133
|
+
groupCode?: string;
|
|
134
|
+
unit?: string;
|
|
135
|
+
options?: Array<DtoOptionConfiguration>;
|
|
136
|
+
}
|
|
150
137
|
/** FeatureRef */
|
|
151
138
|
export interface DtoFeatureRef {
|
|
152
139
|
code: string;
|
|
@@ -176,7 +163,7 @@ export interface DtoGetPriceListsParams {
|
|
|
176
163
|
vendor: string;
|
|
177
164
|
priceList: string;
|
|
178
165
|
}
|
|
179
|
-
/**
|
|
166
|
+
/** GetProductParams represents the URL parameters of getProduct */
|
|
180
167
|
export interface DtoGetProductParams {
|
|
181
168
|
lang: string;
|
|
182
169
|
enterprise: string;
|
|
@@ -261,6 +248,13 @@ export interface DtoOption {
|
|
|
261
248
|
upcharge?: number;
|
|
262
249
|
priceCodes?: Array<string>;
|
|
263
250
|
}
|
|
251
|
+
/** OptionConfiguration */
|
|
252
|
+
export interface DtoOptionConfiguration {
|
|
253
|
+
code: string;
|
|
254
|
+
selected: boolean;
|
|
255
|
+
numericValue?: DtoValueWithUnit;
|
|
256
|
+
features?: Array<DtoFeatureConfiguration>;
|
|
257
|
+
}
|
|
264
258
|
/** Orientation */
|
|
265
259
|
export interface DtoOrientation {
|
|
266
260
|
yaw: number;
|
|
@@ -359,6 +353,12 @@ export interface DtoProductCatalogueInfo {
|
|
|
359
353
|
exchangeRate: number;
|
|
360
354
|
lastModified: string;
|
|
361
355
|
}
|
|
356
|
+
/** ProductConfiguration */
|
|
357
|
+
export interface DtoProductConfiguration {
|
|
358
|
+
features?: Array<DtoFeatureConfiguration>;
|
|
359
|
+
additionalProducts?: Array<DtoAdditionalProductConfigurationV2>;
|
|
360
|
+
prodParams?: DtoProductParamsWithLang;
|
|
361
|
+
}
|
|
362
362
|
/** ProductData */
|
|
363
363
|
export interface DtoProductData {
|
|
364
364
|
area?: string;
|
package/dist/CatalogueAPI.js
CHANGED
|
@@ -9,28 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
|
-
export const dtoExportFormatNames = [
|
|
13
|
-
|
|
14
|
-
"gltf",
|
|
15
|
-
"fbx",
|
|
16
|
-
"dwg",
|
|
17
|
-
"cmdrw",
|
|
18
|
-
"cmfav",
|
|
19
|
-
"cmsym",
|
|
20
|
-
];
|
|
21
|
-
export const dtoExportStatusStatusNames = [
|
|
22
|
-
"pending",
|
|
23
|
-
"running",
|
|
24
|
-
"finished",
|
|
25
|
-
"failed",
|
|
26
|
-
];
|
|
12
|
+
export const dtoExportFormatNames = ["glb", "gltf", "fbx", "dwg", "cmdrw", "cmfav", "cmsym"];
|
|
13
|
+
export const dtoExportStatusStatusNames = ["pending", "running", "finished", "failed"];
|
|
27
14
|
export const dtoRenderFormatNames = ["jpg", "png"];
|
|
28
|
-
export const dtoRenderStatusStatusNames = [
|
|
29
|
-
"pending",
|
|
30
|
-
"running",
|
|
31
|
-
"finished",
|
|
32
|
-
"failed",
|
|
33
|
-
];
|
|
15
|
+
export const dtoRenderStatusStatusNames = ["pending", "running", "finished", "failed"];
|
|
34
16
|
export const dtoSyncGroupMethodsNames = ["pull", "push", "twoWay"];
|
|
35
17
|
export class DtoAPIError extends Error {
|
|
36
18
|
}
|
|
@@ -49,9 +31,7 @@ export class CatalogueAPI {
|
|
|
49
31
|
}
|
|
50
32
|
}
|
|
51
33
|
hasFeature(feature) {
|
|
52
|
-
return
|
|
53
|
-
this.auth.apiSession.features !== undefined &&
|
|
54
|
-
this.auth.apiSession.features.indexOf(feature) > -1);
|
|
34
|
+
return this.auth !== undefined && this.auth.apiSession.features !== undefined && this.auth.apiSession.features.indexOf(feature) > -1;
|
|
55
35
|
}
|
|
56
36
|
fetch(url, options) {
|
|
57
37
|
return __awaiter(this, void 0, void 0, function* () {
|
package/dist/CfgProduct.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AggregatedLoadingObservable, LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
|
|
2
|
-
import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParams,
|
|
2
|
+
import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParams, DtoMeasureParam, DtoMtrlApplication, DtoPrices, DtoProductConfiguration, DtoProductParamsWithLang, DtoTransform } from "./CatalogueAPI.js";
|
|
3
3
|
import { CfgMeasureDefinition } from "./CfgMeasure.js";
|
|
4
4
|
import { _CfgFeatureInternal } from "./productConfiguration/CfgFeature.js";
|
|
5
5
|
import { ProductConfigurationBubbleMode } from "./productConfiguration/CfgOption.js";
|
|
@@ -136,8 +136,8 @@ export declare class _CfgProductInternal {
|
|
|
136
136
|
_additionalProductHasChanged: (freshRef: CfgProduct, bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
|
|
137
137
|
/** Called by the configuration to tell its parent that it has changed. */
|
|
138
138
|
_configurationHasChanged: (freshRef: CfgProductConfiguration, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
|
|
139
|
-
getDtoConf: (includeExtendedData: boolean, includeProductParams: boolean) =>
|
|
140
|
-
setDtoConf: (s:
|
|
139
|
+
getDtoConf: (includeExtendedData: boolean, includeProductParams: boolean) => DtoProductConfiguration;
|
|
140
|
+
setDtoConf: (s: DtoProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
|
|
141
141
|
setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
|
|
142
142
|
copyFrom: (source: _CfgProductInternal, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
|
|
143
143
|
private _setApiSelectionWithOtherProduct;
|
|
@@ -256,8 +256,8 @@ export declare class CfgProduct {
|
|
|
256
256
|
* selections on a product is needed, such as when doing Render or Export.
|
|
257
257
|
*/
|
|
258
258
|
getApiSelection: () => DtoAdditionalProductConfiguration;
|
|
259
|
-
getDtoConf: (includeExtendedData?: boolean, includeProductParams?: boolean) =>
|
|
260
|
-
setDtoConf: (s:
|
|
259
|
+
getDtoConf: (includeExtendedData?: boolean, includeProductParams?: boolean) => DtoProductConfiguration;
|
|
260
|
+
setDtoConf: (s: DtoProductConfiguration, doValidate?: boolean) => Promise<boolean>;
|
|
261
261
|
setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate?: boolean) => Promise<boolean>;
|
|
262
262
|
listenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
|
|
263
263
|
stopListenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
|
package/dist/CfgProduct.js
CHANGED
|
@@ -164,9 +164,11 @@ export class _CfgProductInternal {
|
|
|
164
164
|
}
|
|
165
165
|
return conf;
|
|
166
166
|
};
|
|
167
|
-
this.setDtoConf = (s, doValidate, productLoaderForGroupedLoad) => this
|
|
167
|
+
this.setDtoConf = (s, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
return yield this.setApiSelection(convertDtoConfProdToV1(s), doValidate, productLoaderForGroupedLoad);
|
|
169
|
+
});
|
|
168
170
|
this.setApiSelection = (s, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
return this._setApiSelectionWithOtherProduct(s, doValidate, productLoaderForGroupedLoad, undefined);
|
|
171
|
+
return yield this._setApiSelectionWithOtherProduct(s, doValidate, productLoaderForGroupedLoad, undefined);
|
|
170
172
|
});
|
|
171
173
|
this.copyFrom = (source, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
|
|
172
174
|
return yield this._setApiSelectionWithOtherProduct(convertDtoConfProdToV1(source.getDtoConf(false, false)), doValidate, productLoaderForGroupedLoad, source);
|
|
@@ -203,8 +205,8 @@ export class _CfgProductInternal {
|
|
|
203
205
|
const sourceProductAdditionalProducts = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.additionalProducts;
|
|
204
206
|
assert(!sourceProductAdditionalProducts ||
|
|
205
207
|
additionalProductsCount === sourceProductAdditionalProducts.length, `Passed sourceProduct does not have the same number of additional products as this.`);
|
|
206
|
-
if ((yield Promise.all(apiSelectionAdditionalProducts.map((apiSelectionAdditionalProduct,
|
|
207
|
-
var
|
|
208
|
+
if ((yield Promise.all(apiSelectionAdditionalProducts.map((apiSelectionAdditionalProduct) => __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
var _b;
|
|
208
210
|
const refKey = apiSelectionAdditionalProduct.refKey;
|
|
209
211
|
assertDefined(refKey, "Additional product api configurations must have refKey.");
|
|
210
212
|
const i = additionalProducts.findIndex((a) => refKey === a.refKey);
|
|
@@ -212,12 +214,12 @@ export class _CfgProductInternal {
|
|
|
212
214
|
let sourceProductAdditionalProduct = undefined;
|
|
213
215
|
if (sourceProductAdditionalProducts !== undefined) {
|
|
214
216
|
sourceProductAdditionalProduct =
|
|
215
|
-
(
|
|
217
|
+
(_b = sourceProductAdditionalProducts.find((a) => refKey === a.refKey)) === null || _b === void 0 ? void 0 : _b._internal;
|
|
216
218
|
assertDefined(sourceProductAdditionalProduct, "Additional product not found in sourceProduct");
|
|
217
219
|
}
|
|
218
220
|
const additionalProduct = additionalProducts.splice(i, 1)[0]; // Splicing like this is okay because this is done synchronous. The setCon. is what is async.
|
|
219
|
-
return additionalProduct._internal._setApiSelectionWithOtherProduct(apiSelectionAdditionalProduct, doValidate, productLoaderForGroupedLoad, sourceProductAdditionalProduct);
|
|
220
|
-
}))).some((b) => b)) {
|
|
221
|
+
return yield additionalProduct._internal._setApiSelectionWithOtherProduct(apiSelectionAdditionalProduct, doValidate, productLoaderForGroupedLoad, sourceProductAdditionalProduct);
|
|
222
|
+
})))).some((b) => b)) {
|
|
221
223
|
change = true;
|
|
222
224
|
}
|
|
223
225
|
if (doValidate && configurationChange) {
|
|
@@ -419,7 +421,7 @@ export class _CfgProductInternal {
|
|
|
419
421
|
}
|
|
420
422
|
});
|
|
421
423
|
this.root = root !== null && root !== void 0 ? root : this;
|
|
422
|
-
this.key = makeProductKey(prodParams, (_a = _additionalProductRef === null || _additionalProductRef === void 0 ? void 0 : _additionalProductRef.refKey) !== null && _a !== void 0 ? _a : prodParams.partNumber);
|
|
424
|
+
this.key = makeProductKey(Object.assign(Object.assign({}, prodParams), { partNumber: (_a = _additionalProductRef === null || _additionalProductRef === void 0 ? void 0 : _additionalProductRef.refKey) !== null && _a !== void 0 ? _a : prodParams.partNumber }));
|
|
423
425
|
this._selected = optional ? selected : undefined;
|
|
424
426
|
this.isAdditionalProduct = parent !== undefined;
|
|
425
427
|
this._configuration = CfgProductConfiguration.make(initSuccess, initFail, rootFeatureRefs, allRawFeatures, apiSelection, this, this.root);
|
|
@@ -8,7 +8,20 @@ import { DtoCatalogueParamsWithLang, DtoProductParamsWithLang } from "./Catalogu
|
|
|
8
8
|
* Internally at Configura we try to stick with this format.
|
|
9
9
|
*/
|
|
10
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
|
+
*/
|
|
11
17
|
static getCataloguePath: (browsingRootUrl: string, catParams: DtoCatalogueParamsWithLang) => string;
|
|
12
|
-
|
|
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: DtoProductParamsWithLang, separator?: string) => string;
|
|
13
26
|
}
|
|
14
27
|
//# sourceMappingURL=CfgReferencePathHelper.d.ts.map
|
|
@@ -9,5 +9,18 @@ import { encodeURIComponents } from "@configura/web-utilities";
|
|
|
9
9
|
*/
|
|
10
10
|
export class CfgReferencePathHelper {
|
|
11
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
|
+
*/
|
|
12
18
|
CfgReferencePathHelper.getCataloguePath = (browsingRootUrl, catParams) => `${browsingRootUrl}/${encodeURIComponents(catParams.cid, catParams.lang, catParams.enterprise, catParams.prdCat, catParams.prdCatVersion, catParams.vendor, catParams.priceList)}`;
|
|
13
|
-
|
|
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,5 @@
|
|
|
1
|
-
import { DtoAdditionalProductConfiguration,
|
|
2
|
-
export declare const isDtoConfProdAdditional: (value:
|
|
3
|
-
export declare const convertDtoConfProdToV1: (conf:
|
|
4
|
-
export declare const convertDtoConfFeaturesToSelOptions: (features:
|
|
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[];
|
|
5
5
|
//# sourceMappingURL=ConfigurationConverter.d.ts.map
|
|
@@ -4,7 +4,8 @@ declare type CfgHistoryManagerMessageData = {
|
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
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
|
|
7
|
+
* used as the "state" in the history-frame, and the qsKeyValues, which are query string
|
|
8
|
+
* key-values used in the URL.
|
|
8
9
|
* When navigating back and forth the stage (message) is used to restore the old state. When
|
|
9
10
|
* opening a window with no prior history the Query String will be used.
|
|
10
11
|
*/
|
|
@@ -14,8 +15,8 @@ export declare type CfgHistoryManagerSendData<D> = {
|
|
|
14
15
|
qsKeyValues: Map<string, string | undefined>;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
|
-
* This class
|
|
18
|
-
*
|
|
18
|
+
* This class is used to coordinate writing and reading to the browser history.
|
|
19
|
+
* It handles messages sent from the connectors.
|
|
19
20
|
*/
|
|
20
21
|
export declare class CfgHistoryManager extends CfgWindowEventManager<"popstate", CfgHistoryManagerSendData<CfgHistoryManagerMessageData>> {
|
|
21
22
|
private static _instance;
|
|
@@ -2,8 +2,8 @@ import { mapQueryString, unmapQueryString } from "@configura/web-utilities";
|
|
|
2
2
|
import { CfgIOManager } from "./CfgIOManager.js";
|
|
3
3
|
import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
|
|
4
4
|
/**
|
|
5
|
-
* This class
|
|
6
|
-
*
|
|
5
|
+
* This class is used to coordinate writing and reading to the browser history.
|
|
6
|
+
* It handles messages sent from the connectors.
|
|
7
7
|
*/
|
|
8
8
|
export class CfgHistoryManager extends CfgWindowEventManager {
|
|
9
9
|
constructor() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DtoProductConfiguration } from "../CatalogueAPI.js";
|
|
2
2
|
import { CfgHistoryManager, CfgHistoryManagerSendData } from "./CfgHistoryManager.js";
|
|
3
3
|
import { CfgIOProdConfConnector, CfgProdConfMessage } from "./CfgIOProdConfConnector.js";
|
|
4
|
-
export declare function dtoConfToString(conf:
|
|
5
|
-
export declare function stringToDtoConf(conf: string):
|
|
4
|
+
export declare function dtoConfToString(conf: DtoProductConfiguration): string;
|
|
5
|
+
export declare function stringToDtoConf(conf: string): DtoProductConfiguration;
|
|
6
6
|
/**
|
|
7
7
|
* Instantiating this will make the browser history (and URL) update with the product configuration.
|
|
8
8
|
*/
|
|
@@ -15,7 +15,7 @@ export declare class CfgHistoryToProdConfConnector extends CfgIOProdConfConnecto
|
|
|
15
15
|
* @param doValidate When popping from the history stack (navigating in the browser), should a navigate call be sent to the server to verify that the product configuration is still valid?
|
|
16
16
|
*/
|
|
17
17
|
constructor(manager: CfgHistoryManager, _useHistoryPush: boolean, _qsKey?: string, doValidate?: boolean);
|
|
18
|
-
protected getInitialProdConf():
|
|
19
|
-
protected makeSendData(conf:
|
|
18
|
+
protected getInitialProdConf(): DtoProductConfiguration | undefined;
|
|
19
|
+
protected makeSendData(conf: DtoProductConfiguration, initial: boolean): CfgHistoryManagerSendData<CfgProdConfMessage>;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=CfgHistoryToProdConfConnector.d.ts.map
|
|
@@ -35,7 +35,7 @@ export class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector {
|
|
|
35
35
|
* @param doValidate When popping from the history stack (navigating in the browser), should a navigate call be sent to the server to verify that the product configuration is still valid?
|
|
36
36
|
*/
|
|
37
37
|
constructor(manager, _useHistoryPush, _qsKey = STAGE_PROD_CONF_MESSAGE_KEY, doValidate = true) {
|
|
38
|
-
super(manager, doValidate,
|
|
38
|
+
super(manager, doValidate, false, false);
|
|
39
39
|
this._useHistoryPush = _useHistoryPush;
|
|
40
40
|
this._qsKey = _qsKey;
|
|
41
41
|
}
|
|
@@ -48,7 +48,7 @@ export class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector {
|
|
|
48
48
|
}
|
|
49
49
|
makeSendData(conf, initial) {
|
|
50
50
|
return {
|
|
51
|
-
message:
|
|
51
|
+
message: CfgIOProdConfConnector.makeMessage(conf, initial, CfgProdConfMessageVersions.V2dot0),
|
|
52
52
|
qsKeyValues: new Map([[STAGE_PROD_CONF_MESSAGE_KEY, dtoConfToString(conf)]]),
|
|
53
53
|
useHistoryPush: this._useHistoryPush,
|
|
54
54
|
};
|
|
@@ -1,53 +1,56 @@
|
|
|
1
|
-
import { DtoAdditionalProductConfiguration,
|
|
1
|
+
import { DtoAdditionalProductConfiguration, DtoProductConfiguration } from "../CatalogueAPI.js";
|
|
2
2
|
import { CfgProduct, CfgProductChangeNotification } from "../CfgProduct.js";
|
|
3
3
|
import { CfgIOManager } from "./CfgIOManager.js";
|
|
4
|
+
export declare const isCfgProdConfMessage: (data: unknown) => data is CfgProdConfMessageV1 | CfgProdConfMessageV2;
|
|
4
5
|
export declare type CfgProdConfMessageV1 = {
|
|
5
6
|
version: "1.0";
|
|
6
7
|
conf: DtoAdditionalProductConfiguration;
|
|
7
8
|
};
|
|
9
|
+
export declare const isCfgProdConfMessageV1: (data: unknown) => data is CfgProdConfMessageV1;
|
|
8
10
|
export declare type CfgProdConfMessageV2 = {
|
|
9
11
|
version: "2.0";
|
|
10
|
-
conf:
|
|
12
|
+
conf: DtoProductConfiguration;
|
|
11
13
|
};
|
|
14
|
+
export declare const isCfgProdConfMessageV2: (data: unknown) => data is CfgProdConfMessageV2;
|
|
12
15
|
export declare type CfgProdConfMessage = {
|
|
13
16
|
initial: boolean;
|
|
14
17
|
subMessages: (CfgProdConfMessageV1 | CfgProdConfMessageV2)[];
|
|
15
18
|
};
|
|
19
|
+
export declare const getHighestVersionProdConfMessage: (subMessages: (CfgProdConfMessageV1 | CfgProdConfMessageV2)[]) => CfgProdConfMessageV1 | CfgProdConfMessageV2;
|
|
16
20
|
export declare enum CfgProdConfMessageVersions {
|
|
17
21
|
V1dot0 = 1,
|
|
18
22
|
V2dot0 = 2
|
|
19
23
|
}
|
|
20
24
|
export declare const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
21
25
|
declare type ProdConfMessageCallback = (message: CfgProdConfMessage) => Promise<void>;
|
|
22
|
-
declare type ProdConfCallback = (conf:
|
|
26
|
+
declare type ProdConfCallback = (conf: DtoProductConfiguration) => Promise<void>;
|
|
23
27
|
/**
|
|
24
28
|
* Base class for connecting the product configuration to an IO channel
|
|
25
29
|
*/
|
|
26
30
|
export declare abstract class CfgIOProdConfConnector<S> {
|
|
27
31
|
private readonly _ioManager;
|
|
28
32
|
private readonly _doValidate;
|
|
29
|
-
private readonly _sendVersions;
|
|
30
33
|
private readonly _includeExtendedDataInSend;
|
|
31
34
|
private readonly _includeProdParamsInSend;
|
|
32
35
|
private _product;
|
|
33
36
|
private _stopListenToMessage;
|
|
34
37
|
private _stopListenToProdConf;
|
|
35
|
-
constructor(_ioManager: CfgIOManager<S>, _doValidate: boolean,
|
|
38
|
+
constructor(_ioManager: CfgIOManager<S>, _doValidate: boolean, _includeExtendedDataInSend: boolean, // Only v2.0
|
|
36
39
|
_includeProdParamsInSend: boolean);
|
|
37
40
|
destroy: () => void;
|
|
38
41
|
setProduct: (product: CfgProduct | undefined) => Promise<void>;
|
|
39
42
|
private _send;
|
|
40
|
-
protected getInitialProdConf():
|
|
41
|
-
protected abstract makeSendData(conf:
|
|
42
|
-
makeMessage(conf:
|
|
43
|
-
makeMessageListener(callback: ProdConfMessageCallback): (message: unknown) => Promise<void>;
|
|
43
|
+
protected getInitialProdConf(): DtoProductConfiguration | undefined;
|
|
44
|
+
protected abstract makeSendData(conf: DtoProductConfiguration, initial: boolean): S;
|
|
45
|
+
static makeMessage(conf: DtoProductConfiguration, initial: boolean, sendVersions: CfgProdConfMessageVersions): CfgProdConfMessage;
|
|
46
|
+
static makeMessageListener(callback: ProdConfMessageCallback): (message: unknown) => Promise<void>;
|
|
44
47
|
/**
|
|
45
48
|
* Register the callback to listen for Product Configuration messages
|
|
46
49
|
* @returns A function which when called will cancel listening
|
|
47
50
|
*/
|
|
48
|
-
listenForMessage(callback: ProdConfMessageCallback): () => void;
|
|
49
|
-
makeProdConfListener(callback: ProdConfCallback): (n: CfgProductChangeNotification) => void;
|
|
50
|
-
listenForProdConf(product: CfgProduct, callback: ProdConfCallback): () => void;
|
|
51
|
+
static listenForMessage<S>(callback: ProdConfMessageCallback, ioManager: CfgIOManager<S>): () => void;
|
|
52
|
+
static makeProdConfListener(callback: ProdConfCallback, includeExtendedDataInSend: boolean, includeProdParamsInSend: boolean): (n: CfgProductChangeNotification) => void;
|
|
53
|
+
static listenForProdConf(product: CfgProduct, callback: ProdConfCallback, includeExtendedDataInSend: boolean, includeProdParamsInSend: boolean): () => void;
|
|
51
54
|
}
|
|
52
55
|
export {};
|
|
53
56
|
//# sourceMappingURL=CfgIOProdConfConnector.d.ts.map
|
|
@@ -8,6 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { convertDtoConfProdToV1 } from "../ConfigurationConverter.js";
|
|
11
|
+
export const isCfgProdConfMessage = (data) => typeof data === "object" && data !== null && "version" in data && "conf" in data;
|
|
12
|
+
export const isCfgProdConfMessageV1 = (data) => isCfgProdConfMessage(data) && data.version === "1.0";
|
|
13
|
+
export const isCfgProdConfMessageV2 = (data) => isCfgProdConfMessage(data) && data.version === "2.0";
|
|
14
|
+
export const getHighestVersionProdConfMessage = (subMessages) => subMessages
|
|
15
|
+
.slice(1)
|
|
16
|
+
.reduce((a, c) => (a.version < c.version ? c : a), subMessages[0]);
|
|
11
17
|
export var CfgProdConfMessageVersions;
|
|
12
18
|
(function (CfgProdConfMessageVersions) {
|
|
13
19
|
CfgProdConfMessageVersions[CfgProdConfMessageVersions["V1dot0"] = 1] = "V1dot0";
|
|
@@ -18,12 +24,11 @@ export const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
|
18
24
|
* Base class for connecting the product configuration to an IO channel
|
|
19
25
|
*/
|
|
20
26
|
export class CfgIOProdConfConnector {
|
|
21
|
-
constructor(_ioManager, _doValidate,
|
|
27
|
+
constructor(_ioManager, _doValidate, _includeExtendedDataInSend, // Only v2.0
|
|
22
28
|
_includeProdParamsInSend // Only v2.0
|
|
23
29
|
) {
|
|
24
30
|
this._ioManager = _ioManager;
|
|
25
31
|
this._doValidate = _doValidate;
|
|
26
|
-
this._sendVersions = _sendVersions;
|
|
27
32
|
this._includeExtendedDataInSend = _includeExtendedDataInSend;
|
|
28
33
|
this._includeProdParamsInSend = _includeProdParamsInSend;
|
|
29
34
|
this._stopListenToMessage = undefined;
|
|
@@ -59,35 +64,33 @@ export class CfgIOProdConfConnector {
|
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
this._send(this.makeSendData(newProduct.getDtoConf(this._includeExtendedDataInSend, this._includeProdParamsInSend), true));
|
|
62
|
-
this._stopListenToMessage =
|
|
67
|
+
this._stopListenToMessage = CfgIOProdConfConnector.listenForMessage((messages) => __awaiter(this, void 0, void 0, function* () {
|
|
63
68
|
const subMessages = messages.subMessages;
|
|
64
69
|
if (subMessages.length === 0) {
|
|
65
70
|
console.warn(`${STAGE_PROD_CONF_MESSAGE_KEY} message without any submessages. Unexpected.`);
|
|
66
71
|
return;
|
|
67
72
|
}
|
|
68
|
-
const highestVersionMessage = subMessages
|
|
69
|
-
|
|
70
|
-
.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
yield newProduct.setDtoConf(highestVersionMessage.conf, this._doValidate);
|
|
77
|
-
return;
|
|
73
|
+
const highestVersionMessage = getHighestVersionProdConfMessage(subMessages);
|
|
74
|
+
if (isCfgProdConfMessageV1(highestVersionMessage)) {
|
|
75
|
+
yield newProduct.setApiSelection(highestVersionMessage.conf, this._doValidate);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (isCfgProdConfMessageV2(highestVersionMessage)) {
|
|
79
|
+
yield newProduct.setDtoConf(highestVersionMessage.conf, this._doValidate);
|
|
80
|
+
return;
|
|
78
81
|
}
|
|
79
82
|
throw new Error("Unknown message version");
|
|
80
|
-
}));
|
|
81
|
-
this._stopListenToProdConf =
|
|
83
|
+
}), this._ioManager);
|
|
84
|
+
this._stopListenToProdConf = CfgIOProdConfConnector.listenForProdConf(newProduct, (conf) => __awaiter(this, void 0, void 0, function* () { return this._send(this.makeSendData(conf, false)); }), this._includeExtendedDataInSend, this._includeProdParamsInSend);
|
|
82
85
|
});
|
|
83
86
|
this._send = (data) => this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, data);
|
|
84
87
|
}
|
|
85
88
|
getInitialProdConf() {
|
|
86
89
|
return undefined;
|
|
87
90
|
}
|
|
88
|
-
makeMessage(conf, initial) {
|
|
91
|
+
static makeMessage(conf, initial, sendVersions) {
|
|
89
92
|
const result = [];
|
|
90
|
-
if ((
|
|
93
|
+
if ((sendVersions & CfgProdConfMessageVersions.V1dot0) ===
|
|
91
94
|
CfgProdConfMessageVersions.V1dot0) {
|
|
92
95
|
const v1 = {
|
|
93
96
|
version: "1.0",
|
|
@@ -95,7 +98,7 @@ export class CfgIOProdConfConnector {
|
|
|
95
98
|
};
|
|
96
99
|
result.push(v1);
|
|
97
100
|
}
|
|
98
|
-
if ((
|
|
101
|
+
if ((sendVersions & CfgProdConfMessageVersions.V2dot0) ===
|
|
99
102
|
CfgProdConfMessageVersions.V2dot0) {
|
|
100
103
|
const v2 = {
|
|
101
104
|
version: "2.0",
|
|
@@ -105,7 +108,7 @@ export class CfgIOProdConfConnector {
|
|
|
105
108
|
}
|
|
106
109
|
return { subMessages: result, initial };
|
|
107
110
|
}
|
|
108
|
-
makeMessageListener(callback) {
|
|
111
|
+
static makeMessageListener(callback) {
|
|
109
112
|
return (message) => __awaiter(this, void 0, void 0, function* () {
|
|
110
113
|
const prodConfMessage = message;
|
|
111
114
|
yield callback(prodConfMessage);
|
|
@@ -115,24 +118,23 @@ export class CfgIOProdConfConnector {
|
|
|
115
118
|
* Register the callback to listen for Product Configuration messages
|
|
116
119
|
* @returns A function which when called will cancel listening
|
|
117
120
|
*/
|
|
118
|
-
listenForMessage(callback) {
|
|
119
|
-
const ioManager = this._ioManager;
|
|
121
|
+
static listenForMessage(callback, ioManager) {
|
|
120
122
|
const listener = this.makeMessageListener(callback);
|
|
121
123
|
ioManager.listenForMessage(listener, STAGE_PROD_CONF_MESSAGE_KEY);
|
|
122
124
|
return () => {
|
|
123
125
|
ioManager.stopListenForMessage(listener);
|
|
124
126
|
};
|
|
125
127
|
}
|
|
126
|
-
makeProdConfListener(callback) {
|
|
128
|
+
static makeProdConfListener(callback, includeExtendedDataInSend, includeProdParamsInSend) {
|
|
127
129
|
return (n) => {
|
|
128
130
|
if (!n.committed) {
|
|
129
131
|
return;
|
|
130
132
|
}
|
|
131
|
-
callback(n.freshRef.getDtoConf(
|
|
133
|
+
callback(n.freshRef.getDtoConf(includeExtendedDataInSend, includeProdParamsInSend));
|
|
132
134
|
};
|
|
133
135
|
}
|
|
134
|
-
listenForProdConf(product, callback) {
|
|
135
|
-
const listener = this.makeProdConfListener(callback);
|
|
136
|
+
static listenForProdConf(product, callback, includeExtendedDataInSend, includeProdParamsInSend) {
|
|
137
|
+
const listener = this.makeProdConfListener(callback, includeExtendedDataInSend, includeProdParamsInSend);
|
|
136
138
|
product.listenForChange(listener);
|
|
137
139
|
return () => {
|
|
138
140
|
product.stopListenForChange(listener);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Observable } from "@configura/web-utilities";
|
|
2
2
|
import { CfgIOManager, IOManagerListener } from "./CfgIOManager.js";
|
|
3
|
+
/**
|
|
4
|
+
* This class is used to coordinate sending and receiving using the observable
|
|
5
|
+
* state in the class. It handles messages sent from the connectors.
|
|
6
|
+
*/
|
|
3
7
|
export declare class CfgObservableStateManager extends CfgIOManager<unknown> {
|
|
4
8
|
private static _instance;
|
|
5
9
|
static get instance(): CfgObservableStateManager;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Observable } from "@configura/web-utilities";
|
|
2
2
|
import { CfgIOManager } from "./CfgIOManager.js";
|
|
3
|
+
/**
|
|
4
|
+
* This class is used to coordinate sending and receiving using the observable
|
|
5
|
+
* state in the class. It handles messages sent from the connectors.
|
|
6
|
+
*/
|
|
3
7
|
export class CfgObservableStateManager extends CfgIOManager {
|
|
4
8
|
constructor() {
|
|
5
9
|
super();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DtoProductConfiguration } from "../CatalogueAPI.js";
|
|
2
2
|
import { CfgIOProdConfConnector, CfgProdConfMessage, CfgProdConfMessageVersions } from "./CfgIOProdConfConnector.js";
|
|
3
3
|
import { CfgObservableStateManager } from "./CfgObservableStateManager.js";
|
|
4
4
|
/**
|
|
@@ -9,7 +9,8 @@ import { CfgObservableStateManager } from "./CfgObservableStateManager.js";
|
|
|
9
9
|
* @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
|
|
10
10
|
*/
|
|
11
11
|
export declare class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector<CfgProdConfMessage> {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
private _sendVersions;
|
|
13
|
+
constructor(manager: CfgObservableStateManager, doValidate?: boolean, _sendVersions?: CfgProdConfMessageVersions, includeExtendedDataInSend?: boolean, includeProdParamsInSend?: boolean);
|
|
14
|
+
protected makeSendData(conf: DtoProductConfiguration, initial: boolean): CfgProdConfMessage;
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=CfgObservableStateToProdConfConnector.d.ts.map
|
|
@@ -7,10 +7,11 @@ import { CfgIOProdConfConnector, CfgProdConfMessageVersions, } from "./CfgIOProd
|
|
|
7
7
|
* @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
|
|
8
8
|
*/
|
|
9
9
|
export class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector {
|
|
10
|
-
constructor(manager, doValidate = true,
|
|
11
|
-
super(manager, doValidate,
|
|
10
|
+
constructor(manager, doValidate = true, _sendVersions = CfgProdConfMessageVersions.V2dot0, includeExtendedDataInSend = false, includeProdParamsInSend = false) {
|
|
11
|
+
super(manager, doValidate, includeExtendedDataInSend, includeProdParamsInSend);
|
|
12
|
+
this._sendVersions = _sendVersions;
|
|
12
13
|
}
|
|
13
14
|
makeSendData(conf, initial) {
|
|
14
|
-
return
|
|
15
|
+
return CfgIOProdConfConnector.makeMessage(conf, initial, this._sendVersions);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IOManagerListener } from "./CfgIOManager.js";
|
|
2
2
|
import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
|
|
3
3
|
/**
|
|
4
|
-
* This class
|
|
5
|
-
*
|
|
4
|
+
* This class is used to coordinate sending and receiving using the post message-API.
|
|
5
|
+
* See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
|
|
6
6
|
*/
|
|
7
7
|
export declare class CfgWindowMessageManager extends CfgWindowEventManager<"message", unknown> {
|
|
8
8
|
private static _instance;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CfgIOManager } from "./CfgIOManager.js";
|
|
2
2
|
import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
|
|
3
3
|
/**
|
|
4
|
-
* This class
|
|
5
|
-
*
|
|
4
|
+
* This class is used to coordinate sending and receiving using the post message-API.
|
|
5
|
+
* See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
|
|
6
6
|
*/
|
|
7
7
|
export class CfgWindowMessageManager extends CfgWindowEventManager {
|
|
8
8
|
/**
|
|
@@ -64,6 +64,9 @@ export class CfgWindowMessageManager extends CfgWindowEventManager {
|
|
|
64
64
|
return super.stopListenForMessage(l);
|
|
65
65
|
}
|
|
66
66
|
send(messageKey, data) {
|
|
67
|
+
if (this.receiveInProgress) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
67
70
|
const container = CfgIOManager.makeContainer({
|
|
68
71
|
[messageKey]: data,
|
|
69
72
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DtoProductConfiguration } from "../CatalogueAPI.js";
|
|
2
2
|
import { CfgIOProdConfConnector, CfgProdConfMessage, CfgProdConfMessageVersions } from "./CfgIOProdConfConnector.js";
|
|
3
3
|
import { CfgWindowMessageManager } from "./CfgWindowMessageManager.js";
|
|
4
4
|
/**
|
|
@@ -11,7 +11,8 @@ import { CfgWindowMessageManager } from "./CfgWindowMessageManager.js";
|
|
|
11
11
|
* @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
|
|
12
12
|
*/
|
|
13
13
|
export declare class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector<CfgProdConfMessage> {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
private _sendVersions;
|
|
15
|
+
constructor(manager: CfgWindowMessageManager, doValidate?: boolean, _sendVersions?: CfgProdConfMessageVersions, includeExtendedDataInSend?: boolean, includeProdParamsInSend?: boolean);
|
|
16
|
+
protected makeSendData(conf: DtoProductConfiguration, initial: boolean): CfgProdConfMessage;
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=CfgWindowMessageToProdConfConnector.d.ts.map
|
|
@@ -9,10 +9,11 @@ import { CfgIOProdConfConnector, CfgProdConfMessageVersions, } from "./CfgIOProd
|
|
|
9
9
|
* @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
|
|
10
10
|
*/
|
|
11
11
|
export class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector {
|
|
12
|
-
constructor(manager, doValidate = true,
|
|
13
|
-
super(manager, doValidate,
|
|
12
|
+
constructor(manager, doValidate = true, _sendVersions = CfgProdConfMessageVersions.V2dot0, includeExtendedDataInSend = false, includeProdParamsInSend = false) {
|
|
13
|
+
super(manager, doValidate, includeExtendedDataInSend, includeProdParamsInSend);
|
|
14
|
+
this._sendVersions = _sendVersions;
|
|
14
15
|
}
|
|
15
16
|
makeSendData(conf, initial) {
|
|
16
|
-
return
|
|
17
|
+
return CfgIOProdConfConnector.makeMessage(conf, initial, this._sendVersions);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
|
|
2
|
-
import {
|
|
2
|
+
import { DtoFeature, DtoFeatureConfiguration, DtoSelectedOption, DtoSyncGroup, DtoSyncGroupMethods } from "../CatalogueAPI.js";
|
|
3
3
|
import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
|
|
4
4
|
import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
|
|
5
5
|
import { SyncCode } from "../syncGroups/SyncGroupsHandler.js";
|
|
@@ -99,7 +99,7 @@ export declare class _CfgFeatureInternal {
|
|
|
99
99
|
* as nonexisting children can not call their parent.
|
|
100
100
|
*/
|
|
101
101
|
_childHasChanged: (childOption: _CfgOptionInternal, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
|
|
102
|
-
getDtoConf: (includeExtendedData: boolean) =>
|
|
102
|
+
getDtoConf: (includeExtendedData: boolean) => DtoFeatureConfiguration;
|
|
103
103
|
setApiSelection: (apiOptionSelectionMap: {
|
|
104
104
|
[index: string]: DtoSelectedOption;
|
|
105
105
|
} | undefined) => Promise<boolean>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
|
|
2
|
-
import {
|
|
2
|
+
import { DtoFeature, DtoOption, DtoOptionConfiguration, DtoSelectedOption } from "../CatalogueAPI.js";
|
|
3
3
|
import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
|
|
4
4
|
import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
|
|
5
5
|
import { NumericValuesSelection } from "../utilitiesNumericValues.js";
|
|
@@ -89,7 +89,7 @@ export declare class _CfgOptionInternal {
|
|
|
89
89
|
get features(): CfgFeature[];
|
|
90
90
|
/** Called by child to tell its parent that it has changed. */
|
|
91
91
|
_childHasChanged: (freshRef: CfgFeature, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
|
|
92
|
-
getDtoConf: (includeExtendedData: boolean) =>
|
|
92
|
+
getDtoConf: (includeExtendedData: boolean) => DtoOptionConfiguration;
|
|
93
93
|
setApiSelection: (apiOptionSelection: DtoSelectedOption | undefined) => Promise<boolean>;
|
|
94
94
|
structureCompare: (other: _CfgOptionInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
|
|
95
95
|
tryMatchSelection: (other: CfgOption, descriptionMatch?: boolean) => Promise<boolean>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LengthUnit, LengthValue, Observable, SingleArgCallback } from "@configura/web-utilities";
|
|
2
|
-
import {
|
|
2
|
+
import { DtoFeature, DtoFeatureConfiguration, DtoFeatureRef, DtoSelectedOption } from "../CatalogueAPI.js";
|
|
3
3
|
import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
|
|
4
4
|
import { CfgFeature, _CfgFeatureInternal } from "./CfgFeature.js";
|
|
5
5
|
import { ProductConfigurationBubbleMode } from "./CfgOption.js";
|
|
@@ -34,7 +34,7 @@ export declare class _CfgProductConfigurationInternal {
|
|
|
34
34
|
_freshRefDescendants(): void;
|
|
35
35
|
/** Called by child to tell its parent that it has changed. */
|
|
36
36
|
_childHasChanged: (freshRef: CfgFeature, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
|
|
37
|
-
getDtoConf: (includeExtendedData: boolean) =>
|
|
37
|
+
getDtoConf: (includeExtendedData: boolean) => DtoFeatureConfiguration[];
|
|
38
38
|
/**
|
|
39
39
|
* When used internally the notifications are taken care off by the caller, but if set from
|
|
40
40
|
* outside we want notifications to bubble all the way to the root.
|
package/dist/productLoader.js
CHANGED
|
@@ -21,7 +21,7 @@ import { makeProductKey, makeSelOptionsKey, } from "./utilitiesCatalogueData.js"
|
|
|
21
21
|
*/
|
|
22
22
|
export function wrapWithGetProductCache(getProduct) {
|
|
23
23
|
const cache = new PromiseCache();
|
|
24
|
-
return (params) => __awaiter(this, void 0, void 0, function* () { return cache.get(makeProductKey(params
|
|
24
|
+
return (params) => __awaiter(this, void 0, void 0, function* () { return cache.get(makeProductKey(params), () => getProduct(params)); });
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Wraps a postValidate function so that it caches for the time it lives.
|
|
@@ -37,7 +37,7 @@ export function wrapWithGetProductCache(getProduct) {
|
|
|
37
37
|
export function wrapWithPostValidateCache(postValidate) {
|
|
38
38
|
const cache = new PromiseCache();
|
|
39
39
|
return (params, body) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
return cache.get(`${makeProductKey(params
|
|
40
|
+
return cache.get(`${makeProductKey(params)}-${makeSelOptionsKey(body.selOptions)}`, () => postValidate(params, body));
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
/** Does both wrapWithGetProductCache and wrapWithPostValidateCache. */
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { DtoAdditionalProductRef, DtoCatalogueParams, DtoCatalogueParamsWithLang, DtoCatalogueParamsWithoutCid, DtoMeasureParam, DtoModel, DtoOrientation, DtoPartsData, DtoPrices, DtoProductData, DtoProductParams, DtoProductParamsWithLang, DtoProductResponse, DtoSelectedOption, DtoTransform, DtoValidateResponse, DtoVector } from "./CatalogueAPI.js";
|
|
2
|
+
/**
|
|
3
|
+
* Makes a string from the params which can be used as a key in for example React. Language is not respected.
|
|
4
|
+
*/
|
|
2
5
|
export declare const makeCatalogueKey: (cat: DtoCatalogueParams) => string;
|
|
3
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Makes a string from the params which can be used as a key in for example React. Language is not respected.
|
|
8
|
+
*/
|
|
9
|
+
export declare const makeProductKey: (prod: DtoProductParams) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Makes a string from selected options, can be used as a key for a selection.
|
|
12
|
+
*/
|
|
4
13
|
export declare const makeSelOptionsKey: (options: DtoSelectedOption[]) => string;
|
|
5
14
|
export declare type RootNodeSource = DtoModel | File;
|
|
6
15
|
export declare type CfgProductData = Omit<Omit<DtoProductData, "models">, "partsData"> & {
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { shallowCompareDictionaries } from "@configura/web-utilities";
|
|
2
|
+
/**
|
|
3
|
+
* Makes a string from the params which can be used as a key in for example React. Language is not respected.
|
|
4
|
+
*/
|
|
2
5
|
export const makeCatalogueKey = (cat) => `${cat.cid}-${cat.enterprise}-${cat.prdCat}-${cat.prdCatVersion}-${cat.priceList}-${cat.vendor}`;
|
|
3
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Makes a string from the params which can be used as a key in for example React. Language is not respected.
|
|
8
|
+
*/
|
|
9
|
+
export const makeProductKey = (prod) => `${makeCatalogueKey(prod)}-${prod.partNumber}`;
|
|
10
|
+
/**
|
|
11
|
+
* Makes a string from selected options, can be used as a key for a selection.
|
|
12
|
+
*/
|
|
4
13
|
export const makeSelOptionsKey = (options) => options.reduce((p, option) => {
|
|
5
14
|
var _a;
|
|
6
15
|
const { code, numericValue, next } = option;
|
|
@@ -4,14 +4,20 @@ interface CataloguePermissionByEnterpriseKey {
|
|
|
4
4
|
}
|
|
5
5
|
export declare const groupAndSortCataloguePermissions: (cataloguePermissions: DtoCataloguePermission[]) => CataloguePermissionByEnterpriseKey;
|
|
6
6
|
export declare const isParamSet: (param: string | undefined) => boolean;
|
|
7
|
-
export declare const createCataloguePermissionsFilter: (
|
|
7
|
+
export declare const createCataloguePermissionsFilter: (catParams: Partial<DtoCatalogueParams>) => (perm: DtoCataloguePermission) => boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Sometimes you will want to use the latest available prdCatVersion. This method will
|
|
10
10
|
* find the highest prdCatVersion version in the cataloguePermissions. If the versions are
|
|
11
11
|
* numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
|
|
12
12
|
* string compare.
|
|
13
13
|
*/
|
|
14
|
-
export declare const getPrdCatVersionFromPermissions: (cataloguePermissions: DtoCataloguePermission[],
|
|
14
|
+
export declare const getPrdCatVersionFromPermissions: (cataloguePermissions: DtoCataloguePermission[], catParams: {
|
|
15
|
+
cid: number | undefined;
|
|
16
|
+
enterprise: string | undefined;
|
|
17
|
+
prdCat: string | undefined;
|
|
18
|
+
priceList: string | undefined;
|
|
19
|
+
vendor: string | undefined;
|
|
20
|
+
}) => string | undefined;
|
|
15
21
|
/**
|
|
16
22
|
* Sometimes you will want a missing prdCatVersion to represent "Get the current highest version".
|
|
17
23
|
* This method will, if the prdCatVersion is not set, fetch the highest available from the catalogue
|
|
@@ -15,24 +15,27 @@ export const groupAndSortCataloguePermissions = (cataloguePermissions) => {
|
|
|
15
15
|
return cataloguePermissionByEnterpriseKey;
|
|
16
16
|
};
|
|
17
17
|
export const isParamSet = (param) => param !== undefined && param !== "" && param !== "-";
|
|
18
|
-
export const createCataloguePermissionsFilter = (
|
|
19
|
-
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
export const createCataloguePermissionsFilter = (catParams) => {
|
|
19
|
+
const { cid, enterprise, prdCat, prdCatVersion, vendor, priceList } = catParams;
|
|
20
|
+
return (perm) => (cid === undefined || cid === perm.cid) &&
|
|
21
|
+
(!isParamSet(enterprise) || enterprise === perm.enterprise) &&
|
|
22
|
+
(!isParamSet(prdCat) || prdCat === perm.prdCat) &&
|
|
23
|
+
(!isParamSet(prdCatVersion) || prdCatVersion === perm.prdCatVersion) &&
|
|
24
|
+
(!isParamSet(vendor) ||
|
|
25
|
+
perm.vendors === undefined ||
|
|
26
|
+
perm.vendors.some((v) => vendor === v)) &&
|
|
27
|
+
(!isParamSet(priceList) ||
|
|
28
|
+
perm.priceLists === undefined ||
|
|
29
|
+
perm.priceLists.some((p) => priceList === p));
|
|
30
|
+
};
|
|
28
31
|
/**
|
|
29
32
|
* Sometimes you will want to use the latest available prdCatVersion. This method will
|
|
30
33
|
* find the highest prdCatVersion version in the cataloguePermissions. If the versions are
|
|
31
34
|
* numeric ("1", "4.3", "0.2") they will be numerically compared, otherwise non localized
|
|
32
35
|
* string compare.
|
|
33
36
|
*/
|
|
34
|
-
export const getPrdCatVersionFromPermissions = (cataloguePermissions,
|
|
35
|
-
const filter = createCataloguePermissionsFilter(
|
|
37
|
+
export const getPrdCatVersionFromPermissions = (cataloguePermissions, catParams) => {
|
|
38
|
+
const filter = createCataloguePermissionsFilter(Object.assign(Object.assign({}, catParams), { prdCatVersion: undefined }));
|
|
36
39
|
const applicablePermissions = cataloguePermissions.filter(filter);
|
|
37
40
|
return applicablePermissions.reduce((pVersion, c) => {
|
|
38
41
|
const cVersion = c.prdCatVersion;
|
|
@@ -55,11 +58,11 @@ export const getPrdCatVersionFromPermissions = (cataloguePermissions, cid, enter
|
|
|
55
58
|
* @param params
|
|
56
59
|
*/
|
|
57
60
|
export const getPrdCatVersionOrLatestFromPermissions = (params, cataloguePermissions) => {
|
|
58
|
-
const {
|
|
61
|
+
const { prdCatVersion } = params;
|
|
59
62
|
if (isParamSet(prdCatVersion)) {
|
|
60
63
|
return prdCatVersion;
|
|
61
64
|
}
|
|
62
|
-
const highestFoundVersion = getPrdCatVersionFromPermissions(cataloguePermissions,
|
|
65
|
+
const highestFoundVersion = getPrdCatVersionFromPermissions(cataloguePermissions, params);
|
|
63
66
|
if (highestFoundVersion === undefined) {
|
|
64
67
|
return prdCatVersion;
|
|
65
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/web-api",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
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": "2.0.0-alpha.
|
|
26
|
+
"@configura/web-utilities": "2.0.0-alpha.10"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "77f9cbe7521be3fd58a139bdc93167a349ef384f"
|
|
29
29
|
}
|