@configura/web-api 1.6.1 → 2.0.0-alpha.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.
- package/dist/CatalogueAPI.d.ts +200 -156
- package/dist/CatalogueAPI.js +23 -10
- package/dist/CfgMeasure.d.ts +3 -3
- package/dist/CfgProduct.d.ts +31 -21
- package/dist/CfgProduct.js +77 -46
- package/dist/CfgReferencePathHelper.d.ts +14 -0
- package/dist/CfgReferencePathHelper.js +13 -0
- package/dist/ConfigurationConverter.d.ts +5 -0
- package/dist/ConfigurationConverter.js +72 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/io/CfgHistoryManager.d.ts +51 -0
- package/dist/io/CfgHistoryManager.js +82 -0
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -0
- package/dist/io/CfgHistoryToProdConfConnector.js +56 -0
- package/dist/io/CfgIOManager.d.ts +49 -0
- package/dist/io/CfgIOManager.js +115 -0
- package/dist/io/CfgIOProdConfConnector.d.ts +53 -0
- package/dist/io/CfgIOProdConfConnector.js +141 -0
- package/dist/io/CfgObservableStateManager.d.ts +22 -0
- package/dist/io/CfgObservableStateManager.js +65 -0
- package/dist/io/CfgObservableStateToProdConfConnector.d.ts +15 -0
- package/dist/io/CfgObservableStateToProdConfConnector.js +16 -0
- package/dist/io/CfgWindowEventManager.d.ts +22 -0
- package/dist/io/CfgWindowEventManager.js +38 -0
- package/dist/io/CfgWindowMessageManager.d.ts +41 -0
- package/dist/io/CfgWindowMessageManager.js +84 -0
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +17 -0
- package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -0
- package/dist/io/index.d.ts +9 -0
- package/dist/io/index.js +8 -0
- package/dist/material/CfgMtrlApplication.d.ts +2 -2
- package/dist/productConfiguration/CfgFeature.d.ts +11 -12
- package/dist/productConfiguration/CfgFeature.js +37 -28
- package/dist/productConfiguration/CfgOption.d.ts +9 -8
- package/dist/productConfiguration/CfgOption.js +20 -30
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +17 -20
- package/dist/productConfiguration/CfgProductConfiguration.js +14 -16
- package/dist/productConfiguration/filters.d.ts +4 -4
- package/dist/productConfiguration/productParamsGenerator.d.ts +4 -4
- package/dist/productConfiguration/productParamsGenerator.js +5 -5
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +3 -3
- package/dist/productLoader.d.ts +3 -3
- package/dist/syncGroups/SyncGroupsHandler.js +3 -2
- package/dist/syncGroups/SyncGroupsTransaction.js +1 -1
- package/dist/tasks/TaskHandler.d.ts +7 -8
- package/dist/tasks/TaskHandler.js +4 -5
- package/dist/tasks/formats.d.ts +4 -4
- package/dist/tasks/formats.js +3 -3
- package/dist/tests/testData/dummyProductForTest.d.ts +2 -2
- package/dist/tests/testData/dummyProductForTest.js +3 -7
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +2 -2
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +1 -1
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +2 -2
- package/dist/tests/testData/testDataCachedGetProduct.js +1 -1
- package/dist/tests/testData/testDataCachedPostValidate.js +1 -1
- package/dist/tests/testData/testDataOptions.d.ts +4 -4
- package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +3 -3
- package/dist/tests/testData/testDataProductAggregatedPrice.js +1 -1
- package/dist/tests/testData/testDataUpcharge.js +1 -1
- package/dist/utilitiesCatalogueData.d.ts +25 -23
- package/dist/utilitiesCatalogueData.js +10 -8
- package/dist/utilitiesCataloguePermission.d.ts +8 -13
- package/dist/utilitiesCataloguePermission.js +7 -11
- package/dist/utilitiesNumericValues.d.ts +3 -3
- package/package.json +3 -3
package/dist/CatalogueAPI.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
// WARNING: This file was auto generated by the code in web-rnd/tygen.
|
|
2
|
+
// Do not commit manual changes to this file.
|
|
3
3
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
4
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
5
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -9,7 +9,7 @@ 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
|
|
12
|
+
export const dtoExportFormatNames = [
|
|
13
13
|
"glb",
|
|
14
14
|
"gltf",
|
|
15
15
|
"fbx",
|
|
@@ -18,21 +18,21 @@ export const exportFormatNames = [
|
|
|
18
18
|
"cmfav",
|
|
19
19
|
"cmsym",
|
|
20
20
|
];
|
|
21
|
-
export const
|
|
21
|
+
export const dtoExportStatusStatusNames = [
|
|
22
22
|
"pending",
|
|
23
23
|
"running",
|
|
24
24
|
"finished",
|
|
25
25
|
"failed",
|
|
26
26
|
];
|
|
27
|
-
export const
|
|
28
|
-
export const
|
|
27
|
+
export const dtoRenderFormatNames = ["jpg", "png"];
|
|
28
|
+
export const dtoRenderStatusStatusNames = [
|
|
29
29
|
"pending",
|
|
30
30
|
"running",
|
|
31
31
|
"finished",
|
|
32
32
|
"failed",
|
|
33
33
|
];
|
|
34
|
-
export const
|
|
35
|
-
export class
|
|
34
|
+
export const dtoSyncGroupMethodsNames = ["pull", "push", "twoWay"];
|
|
35
|
+
export class DtoAPIError extends Error {
|
|
36
36
|
}
|
|
37
37
|
export class CatalogueAPI {
|
|
38
38
|
constructor(_fetch = window.fetch.bind(window)) {
|
|
@@ -66,7 +66,7 @@ export class CatalogueAPI {
|
|
|
66
66
|
body = yield response.text();
|
|
67
67
|
const parsed = JSON.parse(body);
|
|
68
68
|
if ("error" in parsed) {
|
|
69
|
-
err = new
|
|
69
|
+
err = new DtoAPIError(parsed.error);
|
|
70
70
|
err.body = body;
|
|
71
71
|
err.status = response.status;
|
|
72
72
|
err.parsed = parsed;
|
|
@@ -77,7 +77,7 @@ export class CatalogueAPI {
|
|
|
77
77
|
}
|
|
78
78
|
catch (e) {
|
|
79
79
|
const msg = e instanceof Error ? e.message : `${e}`;
|
|
80
|
-
err = new
|
|
80
|
+
err = new DtoAPIError(msg);
|
|
81
81
|
err.body = body;
|
|
82
82
|
err.status = response && response.status;
|
|
83
83
|
err.error = e instanceof Error ? e : Error(msg);
|
|
@@ -278,3 +278,16 @@ export class CatalogueAPI {
|
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
+
export const DTO_OPERATION_ID_TO_DEBIT_GROUP = {
|
|
282
|
+
postPublicAccessTokenAuthorize: "base",
|
|
283
|
+
getApplicationAreas: "base",
|
|
284
|
+
postExport: "export",
|
|
285
|
+
getPriceLists: "base",
|
|
286
|
+
getProduct: "base",
|
|
287
|
+
postRender: "render",
|
|
288
|
+
postValidate: "base",
|
|
289
|
+
getTocTree: "base",
|
|
290
|
+
getTocFlat: "base",
|
|
291
|
+
getExportById: "base",
|
|
292
|
+
getRenderById: "base",
|
|
293
|
+
};
|
package/dist/CfgMeasure.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DtoMeasurement, DtoValueWithUnit } from "./CatalogueAPI.js";
|
|
2
2
|
/**
|
|
3
3
|
* Measures can be used to Anchor items (Models or Additional Products).
|
|
4
4
|
*
|
|
@@ -25,9 +25,9 @@ export declare type CfgMeasurePriority = {
|
|
|
25
25
|
*/
|
|
26
26
|
export declare class CfgMeasureDefinition {
|
|
27
27
|
readonly measureParamCode: string;
|
|
28
|
-
readonly numericValue:
|
|
28
|
+
readonly numericValue: DtoValueWithUnit | undefined;
|
|
29
29
|
readonly measurePriorities: CfgMeasurePriority[];
|
|
30
|
-
static make(measurement:
|
|
30
|
+
static make(measurement: DtoMeasurement): CfgMeasureDefinition | undefined;
|
|
31
31
|
private constructor();
|
|
32
32
|
}
|
|
33
33
|
//# sourceMappingURL=CfgMeasure.d.ts.map
|
package/dist/CfgProduct.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AggregatedLoadingObservable, LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
|
|
2
|
-
import {
|
|
2
|
+
import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParams, DtoConfProd, DtoMeasureParam, DtoMtrlApplication, DtoPrices, 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";
|
|
@@ -8,8 +8,16 @@ import { ProductLoader } from "./productLoader.js";
|
|
|
8
8
|
import { SyncGroupsApplyMode } from "./syncGroups/SyncGroupsApplyMode.js";
|
|
9
9
|
import { SyncGroupsHandler } from "./syncGroups/SyncGroupsHandler.js";
|
|
10
10
|
import { CfgProductData, RootNodeSource } from "./utilitiesCatalogueData.js";
|
|
11
|
+
/**
|
|
12
|
+
* @freshRef a new pointer to the same product, backed by the same original object
|
|
13
|
+
* @committed false is an indication that this is a potentially transient state. It could
|
|
14
|
+
* be the expected outcome of a SyncGroups transaction, or dragging to stretch a Product.
|
|
15
|
+
* Uncommitted notifications can be used to update for instance spinners, but should not
|
|
16
|
+
* be sent to server or such.
|
|
17
|
+
*/
|
|
11
18
|
export declare type CfgProductChangeNotification = {
|
|
12
19
|
freshRef: CfgProduct;
|
|
20
|
+
committed: boolean;
|
|
13
21
|
};
|
|
14
22
|
export declare type CfgProductSettings = {
|
|
15
23
|
/**
|
|
@@ -64,9 +72,7 @@ export declare type CfgPrice = {
|
|
|
64
72
|
*/
|
|
65
73
|
export declare class _CfgProductInternal {
|
|
66
74
|
readonly _productLoaderRaw: ProductLoader;
|
|
67
|
-
readonly
|
|
68
|
-
readonly catId: CatalogueParams;
|
|
69
|
-
readonly partNumber: string;
|
|
75
|
+
readonly prodParams: DtoProductParamsWithLang;
|
|
70
76
|
readonly settings: CfgProductSettings;
|
|
71
77
|
readonly uuid: string;
|
|
72
78
|
private readonly _rawUnit;
|
|
@@ -75,7 +81,7 @@ export declare class _CfgProductInternal {
|
|
|
75
81
|
readonly parent: _CfgProductInternal | undefined;
|
|
76
82
|
private _additionalProductRef;
|
|
77
83
|
private readonly _syncGroupHandler;
|
|
78
|
-
static make: (productLoaderRaw: ProductLoader, productLoaderForGroupedLoad: ProductLoader | undefined,
|
|
84
|
+
static make: (productLoaderRaw: ProductLoader, productLoaderForGroupedLoad: ProductLoader | undefined, prodParams: DtoProductParamsWithLang, settings: CfgProductSettings, optional: boolean, loadingObservable: AggregatedLoadingObservable, parent: _CfgProductInternal | undefined, root: _CfgProductInternal | undefined, additionalProductRef: DtoAdditionalProductRef | undefined) => Promise<_CfgProductInternal>;
|
|
79
85
|
private constructor();
|
|
80
86
|
readonly root: _CfgProductInternal;
|
|
81
87
|
private _destroyed;
|
|
@@ -88,19 +94,19 @@ export declare class _CfgProductInternal {
|
|
|
88
94
|
readonly isAdditionalProduct: boolean;
|
|
89
95
|
clone(parent?: _CfgProductInternal, root?: _CfgProductInternal): Promise<_CfgProductInternal>;
|
|
90
96
|
destroy: () => void;
|
|
91
|
-
_updateAdditionalProdRef(p:
|
|
97
|
+
_updateAdditionalProdRef(p: DtoAdditionalProductRef): void;
|
|
92
98
|
get description(): string | undefined;
|
|
93
99
|
get rootNodeSources(): RootNodeSource[] | undefined;
|
|
94
|
-
get mtrlApplications():
|
|
100
|
+
get mtrlApplications(): DtoMtrlApplication[] | undefined;
|
|
95
101
|
get currency(): string;
|
|
96
102
|
get fractionDigits(): number;
|
|
97
|
-
get prices():
|
|
103
|
+
get prices(): DtoPrices | undefined;
|
|
98
104
|
private _measureDefinitions;
|
|
99
105
|
get measureDefinitions(): CfgMeasureDefinition[];
|
|
100
106
|
private _unit;
|
|
101
107
|
get refKey(): string | undefined;
|
|
102
|
-
get transform():
|
|
103
|
-
get anchor():
|
|
108
|
+
get transform(): DtoTransform | undefined;
|
|
109
|
+
get anchor(): DtoMeasureParam | undefined;
|
|
104
110
|
/** @throws an error if the actual unit sent by the server was not a LengthUnit */
|
|
105
111
|
get unit(): LengthUnit;
|
|
106
112
|
get aggregatedPrice(): CfgPrice;
|
|
@@ -123,15 +129,16 @@ export declare class _CfgProductInternal {
|
|
|
123
129
|
* It does not affect the visibility of anything in the 3D view at all.
|
|
124
130
|
*/
|
|
125
131
|
get visible(): boolean;
|
|
126
|
-
_notifyAllOfChange: (bubbleMode: CfgProductBubbleMode) => Promise<void>;
|
|
132
|
+
_notifyAllOfChange: (bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
|
|
127
133
|
/** Called when a child (additional product or the configuration) has changed. */
|
|
128
134
|
private _childHasChanged;
|
|
129
135
|
/** Called by child to tell its parent that it has changed. */
|
|
130
|
-
_additionalProductHasChanged: (freshRef: CfgProduct, bubbleMode: CfgProductBubbleMode) => Promise<void>;
|
|
136
|
+
_additionalProductHasChanged: (freshRef: CfgProduct, bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
|
|
131
137
|
/** Called by the configuration to tell its parent that it has changed. */
|
|
132
|
-
_configurationHasChanged: (freshRef: CfgProductConfiguration, bubbleMode: ProductConfigurationBubbleMode) => Promise<void>;
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
_configurationHasChanged: (freshRef: CfgProductConfiguration, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
|
|
139
|
+
getDtoConf: (includeExtendedData: boolean, includeProductParams: boolean) => DtoConfProd;
|
|
140
|
+
setDtoConf: (s: DtoConfProd, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
|
|
141
|
+
setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
|
|
135
142
|
copyFrom: (source: _CfgProductInternal, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
|
|
136
143
|
private _setApiSelectionWithOtherProduct;
|
|
137
144
|
get syncGroupHandler(): SyncGroupsHandler | undefined;
|
|
@@ -150,7 +157,7 @@ export declare class _CfgProductInternal {
|
|
|
150
157
|
* product in isolation. The validation result is applied on the configuration. Then additional
|
|
151
158
|
* products are synced (unloaded, loaded etc.) Finally the changes bubble up the tree.
|
|
152
159
|
*/
|
|
153
|
-
_revalidate: (bubbleMode: CfgProductBubbleMode, productLoader: ProductLoader) => Promise<boolean>;
|
|
160
|
+
_revalidate: (bubbleMode: CfgProductBubbleMode, productLoader: ProductLoader, committed: boolean) => Promise<boolean>;
|
|
154
161
|
/**
|
|
155
162
|
* Based on this configuration find what additional products should be shown and not, unload
|
|
156
163
|
* (i.e. destroy) those that should no longer be shown, load the new ones.
|
|
@@ -159,7 +166,7 @@ export declare class _CfgProductInternal {
|
|
|
159
166
|
}
|
|
160
167
|
export declare class CfgProduct {
|
|
161
168
|
readonly _internal: _CfgProductInternal;
|
|
162
|
-
static make(productLoader: ProductLoader,
|
|
169
|
+
static make(productLoader: ProductLoader, prodParams: DtoProductParamsWithLang, settings?: Partial<CfgProductSettings>): Promise<CfgProduct>;
|
|
163
170
|
/**
|
|
164
171
|
* Makes an object wrapping the passed object. This is not a clone method, it is a method to
|
|
165
172
|
* make a new outer reference. Like a shallow copy. We use this to help frameworks that are
|
|
@@ -186,8 +193,9 @@ export declare class CfgProduct {
|
|
|
186
193
|
* It will be unique amongst child products, but not globally unique.
|
|
187
194
|
*/
|
|
188
195
|
get refKey(): string | undefined;
|
|
196
|
+
get prodParams(): DtoProductParamsWithLang;
|
|
189
197
|
get lang(): string;
|
|
190
|
-
get catId():
|
|
198
|
+
get catId(): DtoCatalogueParams;
|
|
191
199
|
get partNumber(): string;
|
|
192
200
|
get isAdditionalProduct(): boolean;
|
|
193
201
|
/** Only used when this product is an additional product. Root products are never optional. */
|
|
@@ -220,7 +228,7 @@ export declare class CfgProduct {
|
|
|
220
228
|
get description(): string | undefined;
|
|
221
229
|
get additionalProducts(): CfgProduct[];
|
|
222
230
|
get configuration(): CfgProductConfiguration;
|
|
223
|
-
get transform():
|
|
231
|
+
get transform(): DtoTransform | undefined;
|
|
224
232
|
get currency(): string;
|
|
225
233
|
/**
|
|
226
234
|
* If positive the number of fraction digits.
|
|
@@ -247,8 +255,10 @@ export declare class CfgProduct {
|
|
|
247
255
|
* configuration, optional products and additional products. Used when a full view of all
|
|
248
256
|
* selections on a product is needed, such as when doing Render or Export.
|
|
249
257
|
*/
|
|
250
|
-
getApiSelection: () =>
|
|
251
|
-
|
|
258
|
+
getApiSelection: () => DtoAdditionalProductConfiguration;
|
|
259
|
+
getDtoConf: (includeExtendedData?: boolean, includeProductParams?: boolean) => DtoConfProd;
|
|
260
|
+
setDtoConf: (s: DtoConfProd, doValidate?: boolean) => Promise<boolean>;
|
|
261
|
+
setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate?: boolean) => Promise<boolean>;
|
|
252
262
|
listenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
|
|
253
263
|
stopListenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
|
|
254
264
|
stopAllListenForChange: () => void;
|
package/dist/CfgProduct.js
CHANGED
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { AggregatedLoadingObservable, assert, assertDefined, augmentErrorMessage, compareArrays, count, Observable, toLengthUnit, } from "@configura/web-utilities";
|
|
11
11
|
import { CfgMeasureDefinition } from "./CfgMeasure.js";
|
|
12
|
+
import { convertDtoConfProdToV1 } from "./ConfigurationConverter.js";
|
|
12
13
|
import { ProductConfigurationBubbleMode } from "./productConfiguration/CfgOption.js";
|
|
13
14
|
import { CfgProductConfiguration } from "./productConfiguration/CfgProductConfiguration.js";
|
|
14
15
|
import { collectAdditionalProductRefs } from "./productConfiguration/utilitiesProductConfiguration.js";
|
|
@@ -51,12 +52,10 @@ function isDescriptionMatch(l, r) {
|
|
|
51
52
|
* the class that should be used and interacted with.
|
|
52
53
|
*/
|
|
53
54
|
export class _CfgProductInternal {
|
|
54
|
-
constructor(initSuccess, initFail, _productLoaderRaw,
|
|
55
|
+
constructor(initSuccess, initFail, _productLoaderRaw, prodParams, settings, optional, selected, rootFeatureRefs, allRawFeatures, uuid, _rawUnit, _rawProductData, apiSelection, loadingObservable, parent, root, _additionalProductRef, _syncGroupHandler) {
|
|
55
56
|
var _a;
|
|
56
57
|
this._productLoaderRaw = _productLoaderRaw;
|
|
57
|
-
this.
|
|
58
|
-
this.catId = catId;
|
|
59
|
-
this.partNumber = partNumber;
|
|
58
|
+
this.prodParams = prodParams;
|
|
60
59
|
this.settings = settings;
|
|
61
60
|
this.uuid = uuid;
|
|
62
61
|
this._rawUnit = _rawUnit;
|
|
@@ -76,31 +75,31 @@ export class _CfgProductInternal {
|
|
|
76
75
|
additionalProduct.destroy();
|
|
77
76
|
}
|
|
78
77
|
};
|
|
79
|
-
this._notifyAllOfChange = (bubbleMode) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
this._notifyAllOfChange = (bubbleMode, committed) => __awaiter(this, void 0, void 0, function* () {
|
|
80
79
|
if (bubbleMode === CfgProductBubbleMode.Stop) {
|
|
81
80
|
return;
|
|
82
81
|
}
|
|
83
82
|
const parent = this.parent;
|
|
84
83
|
const freshRef = CfgProduct._makeNewRefFrom(this);
|
|
85
|
-
this.changeObservable.notifyAll({ freshRef });
|
|
84
|
+
this.changeObservable.notifyAll({ freshRef, committed });
|
|
86
85
|
if (parent !== undefined) {
|
|
87
86
|
yield parent._additionalProductHasChanged(freshRef, bubbleMode === CfgProductBubbleMode.OneLevel
|
|
88
87
|
? CfgProductBubbleMode.Stop
|
|
89
|
-
: bubbleMode);
|
|
88
|
+
: bubbleMode, committed);
|
|
90
89
|
}
|
|
91
90
|
});
|
|
92
91
|
/** Called when a child (additional product or the configuration) has changed. */
|
|
93
|
-
this._childHasChanged = (bubbleMode) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
this._childHasChanged = (bubbleMode, committed) => __awaiter(this, void 0, void 0, function* () {
|
|
94
93
|
if (bubbleMode === CfgProductBubbleMode.ToRootAndBubbleSelected &&
|
|
95
94
|
this.optional &&
|
|
96
95
|
!this.selected) {
|
|
97
96
|
yield this.setSelected(true, bubbleMode);
|
|
98
97
|
return;
|
|
99
98
|
}
|
|
100
|
-
yield this._notifyAllOfChange(bubbleMode);
|
|
99
|
+
yield this._notifyAllOfChange(bubbleMode, committed);
|
|
101
100
|
});
|
|
102
101
|
/** Called by child to tell its parent that it has changed. */
|
|
103
|
-
this._additionalProductHasChanged = (freshRef, bubbleMode) => __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
this._additionalProductHasChanged = (freshRef, bubbleMode, committed) => __awaiter(this, void 0, void 0, function* () {
|
|
104
103
|
const i = this.additionalProducts.findIndex((a) => a.isBackedBySame(freshRef));
|
|
105
104
|
if (i !== -1) {
|
|
106
105
|
// Child additional product might not be found. This probably means that propagate
|
|
@@ -110,48 +109,67 @@ export class _CfgProductInternal {
|
|
|
110
109
|
// C no longer is part of the tree. Odd, but fully permitted.
|
|
111
110
|
this.additionalProducts[i] = freshRef;
|
|
112
111
|
}
|
|
113
|
-
yield this._childHasChanged(bubbleMode);
|
|
112
|
+
yield this._childHasChanged(bubbleMode, committed);
|
|
114
113
|
});
|
|
115
114
|
/** Called by the configuration to tell its parent that it has changed. */
|
|
116
|
-
this._configurationHasChanged = (freshRef, bubbleMode) => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
this._configurationHasChanged = (freshRef, bubbleMode, committed) => __awaiter(this, void 0, void 0, function* () {
|
|
117
116
|
this._configuration = freshRef;
|
|
118
117
|
switch (bubbleMode) {
|
|
119
118
|
case ProductConfigurationBubbleMode.ValidateAndBubbleSelected:
|
|
120
119
|
// The revalidate call will continue the bubble
|
|
121
|
-
yield this._revalidate(CfgProductBubbleMode.ToRootAndBubbleSelected, this._productLoaderRaw);
|
|
120
|
+
yield this._revalidate(CfgProductBubbleMode.ToRootAndBubbleSelected, this._productLoaderRaw, committed);
|
|
122
121
|
return;
|
|
123
122
|
case ProductConfigurationBubbleMode.BubbleSelected:
|
|
124
|
-
yield this._childHasChanged(CfgProductBubbleMode.ToRootAndBubbleSelected);
|
|
123
|
+
yield this._childHasChanged(CfgProductBubbleMode.ToRootAndBubbleSelected, committed);
|
|
125
124
|
return;
|
|
126
125
|
case ProductConfigurationBubbleMode.Validate:
|
|
127
126
|
// The revalidate call will continue the bubble
|
|
128
|
-
yield this._revalidate(CfgProductBubbleMode.ToRoot, this._productLoaderRaw);
|
|
127
|
+
yield this._revalidate(CfgProductBubbleMode.ToRoot, this._productLoaderRaw, committed);
|
|
129
128
|
return;
|
|
130
129
|
case ProductConfigurationBubbleMode.ToParentProduct:
|
|
131
130
|
// Do not continue bubble as we have reached the parent CfgProduct
|
|
132
131
|
return;
|
|
133
132
|
case ProductConfigurationBubbleMode.OneLevel:
|
|
134
|
-
yield this._childHasChanged(CfgProductBubbleMode.OneLevel);
|
|
133
|
+
yield this._childHasChanged(CfgProductBubbleMode.OneLevel, committed);
|
|
135
134
|
return;
|
|
136
135
|
case ProductConfigurationBubbleMode.Stop:
|
|
137
|
-
yield this._childHasChanged(CfgProductBubbleMode.Stop);
|
|
136
|
+
yield this._childHasChanged(CfgProductBubbleMode.Stop, committed);
|
|
138
137
|
return;
|
|
139
138
|
case ProductConfigurationBubbleMode.ToRoot:
|
|
140
|
-
yield this._childHasChanged(CfgProductBubbleMode.ToRoot);
|
|
139
|
+
yield this._childHasChanged(CfgProductBubbleMode.ToRoot, committed);
|
|
141
140
|
return;
|
|
142
141
|
}
|
|
143
142
|
});
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
this.getDtoConf = (includeExtendedData, includeProductParams) => {
|
|
144
|
+
const conf = {};
|
|
145
|
+
const features = this.configuration._internal.getDtoConf(includeExtendedData);
|
|
146
|
+
if (0 < features.length) {
|
|
147
|
+
conf.features = features;
|
|
148
|
+
}
|
|
149
|
+
if (includeProductParams) {
|
|
150
|
+
conf.prodParams = this.prodParams;
|
|
151
|
+
}
|
|
152
|
+
const additionalProducts = this.additionalProducts;
|
|
153
|
+
if (0 < additionalProducts.length) {
|
|
154
|
+
conf.additionalProducts = additionalProducts.map((p) => p._internal.getDtoConf(includeExtendedData, includeProductParams));
|
|
155
|
+
}
|
|
156
|
+
if (this.isAdditionalProduct) {
|
|
157
|
+
const refKey = this.refKey;
|
|
158
|
+
if (refKey === undefined) {
|
|
159
|
+
throw new Error("AdditionalProduct without refKey, this should not happen");
|
|
160
|
+
}
|
|
161
|
+
const confAddProd = conf;
|
|
162
|
+
confAddProd.refKey = refKey;
|
|
163
|
+
confAddProd.selected = this.selected;
|
|
164
|
+
}
|
|
165
|
+
return conf;
|
|
166
|
+
};
|
|
167
|
+
this.setDtoConf = (s, doValidate, productLoaderForGroupedLoad) => this.setApiSelection(convertDtoConfProdToV1(s), doValidate, productLoaderForGroupedLoad);
|
|
150
168
|
this.setApiSelection = (s, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
|
|
151
169
|
return this._setApiSelectionWithOtherProduct(s, doValidate, productLoaderForGroupedLoad, undefined);
|
|
152
170
|
});
|
|
153
171
|
this.copyFrom = (source, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
return yield this._setApiSelectionWithOtherProduct(source.
|
|
172
|
+
return yield this._setApiSelectionWithOtherProduct(convertDtoConfProdToV1(source.getDtoConf(false, false)), doValidate, productLoaderForGroupedLoad, source);
|
|
155
173
|
});
|
|
156
174
|
this._setApiSelectionWithOtherProduct = (s, doValidate, productLoaderForGroupedLoad, sourceProduct) => __awaiter(this, void 0, void 0, function* () {
|
|
157
175
|
// Wrap with cache will make getProduct for this function call use the same server call
|
|
@@ -203,13 +221,13 @@ export class _CfgProductInternal {
|
|
|
203
221
|
change = true;
|
|
204
222
|
}
|
|
205
223
|
if (doValidate && configurationChange) {
|
|
206
|
-
yield this._revalidate(CfgProductBubbleMode.ToRoot, productLoaderForGroupedLoad);
|
|
224
|
+
yield this._revalidate(CfgProductBubbleMode.ToRoot, productLoaderForGroupedLoad, true);
|
|
207
225
|
}
|
|
208
226
|
else if (change) {
|
|
209
227
|
// As setApiSelection is done recursively each level takes care of its own notifications
|
|
210
228
|
// so we only need to bubble one level to notify this and swap out the reference in the
|
|
211
229
|
// parent.
|
|
212
|
-
yield this._notifyAllOfChange(CfgProductBubbleMode.OneLevel);
|
|
230
|
+
yield this._notifyAllOfChange(CfgProductBubbleMode.OneLevel, true);
|
|
213
231
|
}
|
|
214
232
|
return change;
|
|
215
233
|
});
|
|
@@ -235,10 +253,10 @@ export class _CfgProductInternal {
|
|
|
235
253
|
const configurationChange = yield this.configuration._internal.tryMatchSelection(other.configuration._internal, descriptionMatch, false);
|
|
236
254
|
if (configurationChange) {
|
|
237
255
|
change = true;
|
|
238
|
-
yield this._revalidate(CfgProductBubbleMode.ToRootAndBubbleSelected, productLoaderForGroupedLoad);
|
|
256
|
+
yield this._revalidate(CfgProductBubbleMode.ToRootAndBubbleSelected, productLoaderForGroupedLoad, true);
|
|
239
257
|
}
|
|
240
258
|
else if (change) {
|
|
241
|
-
yield this._notifyAllOfChange(CfgProductBubbleMode.ToRootAndBubbleSelected);
|
|
259
|
+
yield this._notifyAllOfChange(CfgProductBubbleMode.ToRootAndBubbleSelected, true);
|
|
242
260
|
}
|
|
243
261
|
const thisAdditionalProducts = this.additionalProducts;
|
|
244
262
|
const otherAdditionalProducts = other.additionalProducts;
|
|
@@ -287,12 +305,12 @@ export class _CfgProductInternal {
|
|
|
287
305
|
* product in isolation. The validation result is applied on the configuration. Then additional
|
|
288
306
|
* products are synced (unloaded, loaded etc.) Finally the changes bubble up the tree.
|
|
289
307
|
*/
|
|
290
|
-
this._revalidate = (bubbleMode, productLoader) => __awaiter(this, void 0, void 0, function* () {
|
|
308
|
+
this._revalidate = (bubbleMode, productLoader, committed) => __awaiter(this, void 0, void 0, function* () {
|
|
291
309
|
const { _configuration: configuration } = this;
|
|
292
310
|
const token = this.loadingObservable.startChildLoading();
|
|
293
311
|
this._revalidateInProgressToken = token;
|
|
294
312
|
try {
|
|
295
|
-
const response = yield productLoader.postValidate(
|
|
313
|
+
const response = yield productLoader.postValidate(correctDefaultsOnCatalogueParams(this.prodParams), { selOptions: configuration.getApiSelection() });
|
|
296
314
|
// The revalidateInProgressToken is used to know if some other revalidate
|
|
297
315
|
// call has happened after this call, thereby making this call obsolete.
|
|
298
316
|
// This is a bit crude in that it does not actually cancel previous validate
|
|
@@ -326,7 +344,7 @@ export class _CfgProductInternal {
|
|
|
326
344
|
if (this._destroyed) {
|
|
327
345
|
return false;
|
|
328
346
|
}
|
|
329
|
-
yield this._notifyAllOfChange(bubbleMode);
|
|
347
|
+
yield this._notifyAllOfChange(bubbleMode, committed);
|
|
330
348
|
return true;
|
|
331
349
|
}
|
|
332
350
|
catch (e) {
|
|
@@ -341,7 +359,7 @@ export class _CfgProductInternal {
|
|
|
341
359
|
* (i.e. destroy) those that should no longer be shown, load the new ones.
|
|
342
360
|
*/
|
|
343
361
|
this._syncAndLoadAdditionalProducts = (productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
|
|
344
|
-
const {
|
|
362
|
+
const { _productLoaderRaw: productLoaderRaw, rawProductData: productData, configuration, additionalProducts: currentAdditionalProducts, } = this;
|
|
345
363
|
const additionalProductRefs = [
|
|
346
364
|
...(productData.additionalProductRefs || []),
|
|
347
365
|
...collectAdditionalProductRefs(configuration),
|
|
@@ -385,7 +403,7 @@ export class _CfgProductInternal {
|
|
|
385
403
|
const additionalProductRef = p.prodRef;
|
|
386
404
|
return {
|
|
387
405
|
originalIndex: p.originalIndex,
|
|
388
|
-
product: CfgProduct._makeNewRefFrom(yield _CfgProductInternal.make(productLoaderRaw, productLoaderForGroupedLoad,
|
|
406
|
+
product: CfgProduct._makeNewRefFrom(yield _CfgProductInternal.make(productLoaderRaw, productLoaderForGroupedLoad, Object.assign(Object.assign({}, additionalProductRef.catId), { cid: this.prodParams.cid, lang: this.prodParams.lang, partNumber: additionalProductRef.partNumber }), this.settings, additionalProductRef.optional === true, this.loadingObservable, this, this.root, additionalProductRef)),
|
|
389
407
|
};
|
|
390
408
|
}))()));
|
|
391
409
|
if (this._destroyed) {
|
|
@@ -401,7 +419,7 @@ export class _CfgProductInternal {
|
|
|
401
419
|
}
|
|
402
420
|
});
|
|
403
421
|
this.root = root !== null && root !== void 0 ? root : this;
|
|
404
|
-
this.key = makeProductKey(
|
|
422
|
+
this.key = makeProductKey(prodParams, (_a = _additionalProductRef === null || _additionalProductRef === void 0 ? void 0 : _additionalProductRef.refKey) !== null && _a !== void 0 ? _a : prodParams.partNumber);
|
|
405
423
|
this._selected = optional ? selected : undefined;
|
|
406
424
|
this.isAdditionalProduct = parent !== undefined;
|
|
407
425
|
this._configuration = CfgProductConfiguration.make(initSuccess, initFail, rootFeatureRefs, allRawFeatures, apiSelection, this, this.root);
|
|
@@ -415,7 +433,7 @@ export class _CfgProductInternal {
|
|
|
415
433
|
var _a;
|
|
416
434
|
const p = new _CfgProductInternal(() => {
|
|
417
435
|
initSuccess(p);
|
|
418
|
-
}, initFail, this._productLoaderRaw, this.
|
|
436
|
+
}, initFail, this._productLoaderRaw, this.prodParams, this.settings, this.optional, this.selected, this._configuration.rootFeatureRefs, this._configuration.allRawFeatures, this.uuid, this._rawUnit, this._rawProductData, this.configuration.getApiSelection(), new AggregatedLoadingObservable(), parent, root, this._additionalProductRef, (_a = this._syncGroupHandler) === null || _a === void 0 ? void 0 : _a.clone());
|
|
419
437
|
});
|
|
420
438
|
for (const additionalProduct of this.additionalProducts) {
|
|
421
439
|
product.additionalProducts.push(CfgProduct._makeNewRefFrom(yield additionalProduct._internal.clone(product, root || product)));
|
|
@@ -513,7 +531,7 @@ export class _CfgProductInternal {
|
|
|
513
531
|
return false;
|
|
514
532
|
}
|
|
515
533
|
this._selected = v;
|
|
516
|
-
yield this._notifyAllOfChange(bubbleMode);
|
|
534
|
+
yield this._notifyAllOfChange(bubbleMode, true);
|
|
517
535
|
return true;
|
|
518
536
|
});
|
|
519
537
|
}
|
|
@@ -565,7 +583,7 @@ export class _CfgProductInternal {
|
|
|
565
583
|
}
|
|
566
584
|
}
|
|
567
585
|
_CfgProductInternal.make = (productLoaderRaw, productLoaderForGroupedLoad, // Used when instantiating the current product
|
|
568
|
-
|
|
586
|
+
prodParams, settings, optional, loadingObservable, parent, root, additionalProductRef) => __awaiter(void 0, void 0, void 0, function* () {
|
|
569
587
|
// Wrap with cache will make getProduct for this function call use the same server call
|
|
570
588
|
// for the same product with the same params. Not retained for future calls, only used
|
|
571
589
|
// at this initial load.
|
|
@@ -575,7 +593,7 @@ lang, catId, partNumber, settings, optional, loadingObservable, parent, root, ad
|
|
|
575
593
|
? SyncGroupsHandler.make(settings.syncGroupsApplyMode, loadingObservable)
|
|
576
594
|
: undefined;
|
|
577
595
|
try {
|
|
578
|
-
const productResponse = yield productLoaderForGroupedLoad.getProduct(
|
|
596
|
+
const productResponse = yield productLoaderForGroupedLoad.getProduct(correctDefaultsOnCatalogueParams(prodParams));
|
|
579
597
|
const { productData, rootFeatureRefs, features: allRawFeatures, uuid, unit, } = productResponse;
|
|
580
598
|
const product = yield new Promise((initSuccess, initFail) => {
|
|
581
599
|
const p = new _CfgProductInternal(() => {
|
|
@@ -583,7 +601,7 @@ lang, catId, partNumber, settings, optional, loadingObservable, parent, root, ad
|
|
|
583
601
|
// But we can not set the api selection synchronously. And the product configuration needs "this". So we use this callback.
|
|
584
602
|
// Feel free to find a nicer more readable solution :)
|
|
585
603
|
initSuccess(p);
|
|
586
|
-
}, initFail, productLoaderRaw,
|
|
604
|
+
}, initFail, productLoaderRaw, prodParams, settings, optional, !optional, rootFeatureRefs, allRawFeatures, uuid, unit, productData, productData.partsData.selOptions || [], loadingObservable, parent, root, additionalProductRef, syncGroupHandler);
|
|
587
605
|
});
|
|
588
606
|
yield product._syncAndLoadAdditionalProducts(productLoaderForGroupedLoad);
|
|
589
607
|
// Product is guaranteed to be root
|
|
@@ -631,7 +649,9 @@ export class CfgProduct {
|
|
|
631
649
|
* configuration, optional products and additional products. Used when a full view of all
|
|
632
650
|
* selections on a product is needed, such as when doing Render or Export.
|
|
633
651
|
*/
|
|
634
|
-
this.getApiSelection = () => this._internal.
|
|
652
|
+
this.getApiSelection = () => convertDtoConfProdToV1(this._internal.getDtoConf(false, false), true);
|
|
653
|
+
this.getDtoConf = (includeExtendedData = false, includeProductParams = false) => this._internal.getDtoConf(includeExtendedData, includeProductParams);
|
|
654
|
+
this.setDtoConf = (s, doValidate = false) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.setDtoConf(s, doValidate); });
|
|
635
655
|
this.setApiSelection = (s, doValidate = false) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.setApiSelection(s, doValidate); });
|
|
636
656
|
this.listenForChange = (l) => this._internal.changeObservable.listen(l);
|
|
637
657
|
this.stopListenForChange = (l) => this._internal.changeObservable.stopListen(l);
|
|
@@ -640,9 +660,9 @@ export class CfgProduct {
|
|
|
640
660
|
this.stopListenForLoading = (l) => this._internal.loadingObservable.stopListen(l);
|
|
641
661
|
this.stopAllListenForLoading = () => this._internal.loadingObservable.stopAllListen();
|
|
642
662
|
}
|
|
643
|
-
static make(productLoader,
|
|
663
|
+
static make(productLoader, prodParams, settings) {
|
|
644
664
|
return __awaiter(this, void 0, void 0, function* () {
|
|
645
|
-
return this._makeNewRefFrom(yield _CfgProductInternal.make(productLoader, undefined,
|
|
665
|
+
return this._makeNewRefFrom(yield _CfgProductInternal.make(productLoader, undefined, prodParams, completeSettings(settings), false, new AggregatedLoadingObservable(), undefined, undefined, undefined));
|
|
646
666
|
});
|
|
647
667
|
}
|
|
648
668
|
/**
|
|
@@ -668,14 +688,25 @@ export class CfgProduct {
|
|
|
668
688
|
get refKey() {
|
|
669
689
|
return this._internal.refKey;
|
|
670
690
|
}
|
|
691
|
+
get prodParams() {
|
|
692
|
+
return this._internal.prodParams;
|
|
693
|
+
}
|
|
671
694
|
get lang() {
|
|
672
|
-
return this._internal.lang;
|
|
695
|
+
return this._internal.prodParams.lang;
|
|
673
696
|
}
|
|
674
697
|
get catId() {
|
|
675
|
-
|
|
698
|
+
const { cid, enterprise, prdCat, prdCatVersion, priceList, vendor } = this._internal.prodParams;
|
|
699
|
+
return {
|
|
700
|
+
cid,
|
|
701
|
+
enterprise,
|
|
702
|
+
prdCat,
|
|
703
|
+
prdCatVersion,
|
|
704
|
+
priceList,
|
|
705
|
+
vendor,
|
|
706
|
+
};
|
|
676
707
|
}
|
|
677
708
|
get partNumber() {
|
|
678
|
-
return this._internal.partNumber;
|
|
709
|
+
return this._internal.prodParams.partNumber;
|
|
679
710
|
}
|
|
680
711
|
get isAdditionalProduct() {
|
|
681
712
|
return this._internal.isAdditionalProduct;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
14
|
+
//# sourceMappingURL=CfgReferencePathHelper.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
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)}`;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DtoAdditionalProductConfiguration, DtoConfAddProd, DtoConfFeature, DtoConfProd, DtoSelectedOption } from "./CatalogueAPI.js";
|
|
2
|
+
export declare const isDtoConfProdAdditional: (value: DtoConfProd) => value is DtoConfAddProd;
|
|
3
|
+
export declare const convertDtoConfProdToV1: (conf: DtoConfProd, silenceWarnings?: boolean) => DtoAdditionalProductConfiguration;
|
|
4
|
+
export declare const convertDtoConfFeaturesToSelOptions: (features: DtoConfFeature[], silenceWarnings?: boolean) => DtoSelectedOption[];
|
|
5
|
+
//# sourceMappingURL=ConfigurationConverter.d.ts.map
|