@configura/web-api 2.0.0-alpha.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.eslintrc.json +5 -18
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/CatalogueAPI.d.ts +622 -551
  5. package/dist/CatalogueAPI.js +329 -273
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +344 -268
  9. package/dist/CfgProduct.js +991 -780
  10. package/dist/CfgReferencePathHelper.d.ts +26 -13
  11. package/dist/CfgReferencePathHelper.js +26 -13
  12. package/dist/ConfigurationConverter.d.ts +17 -4
  13. package/dist/ConfigurationConverter.js +175 -72
  14. package/dist/index.d.ts +23 -23
  15. package/dist/index.js +23 -23
  16. package/dist/io/CfgHistoryManager.d.ts +83 -51
  17. package/dist/io/CfgHistoryManager.js +144 -82
  18. package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -20
  19. package/dist/io/CfgHistoryToProdConfConnector.js +50 -56
  20. package/dist/io/CfgIOManager.d.ts +53 -48
  21. package/dist/io/CfgIOManager.js +134 -115
  22. package/dist/io/CfgIOProdConfConnector.d.ts +64 -55
  23. package/dist/io/CfgIOProdConfConnector.js +149 -143
  24. package/dist/io/CfgIOWarningSupplier.d.ts +4 -0
  25. package/dist/io/CfgIOWarningSupplier.js +1 -0
  26. package/dist/io/CfgObservableStateManager.d.ts +25 -25
  27. package/dist/io/CfgObservableStateManager.js +69 -69
  28. package/dist/io/CfgObservableStateToProdConfConnector.d.ts +14 -15
  29. package/dist/io/CfgObservableStateToProdConfConnector.js +16 -17
  30. package/dist/io/CfgWindowEventManager.d.ts +21 -21
  31. package/dist/io/CfgWindowEventManager.js +38 -38
  32. package/dist/io/CfgWindowMessageManager.d.ts +40 -40
  33. package/dist/io/CfgWindowMessageManager.js +91 -87
  34. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +16 -17
  35. package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -19
  36. package/dist/io/index.d.ts +8 -8
  37. package/dist/io/index.js +8 -8
  38. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  39. package/dist/material/CfgMaterialMapping.js +181 -181
  40. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  41. package/dist/material/CfgMtrlApplication.js +43 -43
  42. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  43. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  44. package/dist/material/CfgMtrlSource.d.ts +19 -19
  45. package/dist/material/CfgMtrlSource.js +40 -40
  46. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  47. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  48. package/dist/productConfiguration/CfgFeature.d.ts +192 -187
  49. package/dist/productConfiguration/CfgFeature.js +663 -645
  50. package/dist/productConfiguration/CfgOption.d.ts +157 -151
  51. package/dist/productConfiguration/CfgOption.js +444 -416
  52. package/dist/productConfiguration/CfgProductConfiguration.d.ts +128 -117
  53. package/dist/productConfiguration/CfgProductConfiguration.js +331 -307
  54. package/dist/productConfiguration/filters.d.ts +15 -15
  55. package/dist/productConfiguration/filters.js +70 -70
  56. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  57. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  58. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
  59. package/dist/productConfiguration/utilitiesProductConfiguration.js +87 -80
  60. package/dist/productLoader.d.ts +33 -33
  61. package/dist/productLoader.js +49 -49
  62. package/dist/syncGroups/SyncGroupsApplyMode.d.ts +20 -20
  63. package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
  64. package/dist/syncGroups/SyncGroupsHandler.d.ts +47 -40
  65. package/dist/syncGroups/SyncGroupsHandler.js +370 -359
  66. package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
  67. package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
  68. package/dist/syncGroups/SyncGroupsState.d.ts +39 -35
  69. package/dist/syncGroups/SyncGroupsState.js +167 -125
  70. package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
  71. package/dist/syncGroups/SyncGroupsTransaction.js +589 -576
  72. package/dist/tasks/TaskHandler.d.ts +77 -77
  73. package/dist/tasks/TaskHandler.js +276 -275
  74. package/dist/tasks/formats.d.ts +4 -4
  75. package/dist/tasks/formats.js +7 -7
  76. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  77. package/dist/tests/testData/collectorForTest.js +194 -194
  78. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  79. package/dist/tests/testData/dummyProductForTest.js +32 -32
  80. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
  81. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +282 -277
  82. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  83. package/dist/tests/testData/testDataCachedGetProduct.js +187 -185
  84. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  85. package/dist/tests/testData/testDataCachedPostValidate.js +185 -183
  86. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  87. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
  88. package/dist/tests/testData/testDataOptions.d.ts +12 -12
  89. package/dist/tests/testData/testDataOptions.js +60 -60
  90. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
  91. package/dist/tests/testData/testDataProductAggregatedPrice.js +189 -187
  92. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  93. package/dist/tests/testData/testDataUpcharge.js +121 -119
  94. package/dist/utilitiesCatalogueData.d.ts +47 -42
  95. package/dist/utilitiesCatalogueData.js +180 -173
  96. package/dist/utilitiesCataloguePermission.d.ts +38 -38
  97. package/dist/utilitiesCataloguePermission.js +79 -79
  98. package/dist/utilitiesNumericValues.d.ts +24 -24
  99. package/dist/utilitiesNumericValues.js +114 -109
  100. package/package.json +3 -3
@@ -1,269 +1,345 @@
1
- import { AggregatedLoadingObservable, LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParams, DtoMeasureParam, DtoMtrlApplication, DtoPrices, DtoProductConfiguration, DtoProductParamsWithLang, DtoTransform } from "./CatalogueAPI.js";
3
- import { CfgMeasureDefinition } from "./CfgMeasure.js";
4
- import { _CfgFeatureInternal } from "./productConfiguration/CfgFeature.js";
5
- import { ProductConfigurationBubbleMode } from "./productConfiguration/CfgOption.js";
6
- import { CfgProductConfiguration } from "./productConfiguration/CfgProductConfiguration.js";
7
- import { ProductLoader } from "./productLoader.js";
8
- import { SyncGroupsApplyMode } from "./syncGroups/SyncGroupsApplyMode.js";
9
- import { SyncGroupsHandler } from "./syncGroups/SyncGroupsHandler.js";
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
- */
18
- export declare type CfgProductChangeNotification = {
19
- freshRef: CfgProduct;
20
- committed: boolean;
21
- };
22
- export declare type CfgProductSettings = {
23
- /**
24
- * In a correctly setup catalogue a select-one Feature (i.e. neither optional nor multiple)
25
- * must have exactly one Option set at a time. However, this is not enforced in Catalogue
26
- * Creator and it is not uncommon with catalogues which fails to meet this requirement.
27
- * Activating this will make setApi throw an Error if more or less than one is selected.
28
- */
29
- strictSelectOneSelectionCount: boolean;
30
- /**
31
- * Controls if SyncGroups are applied Faster or Stricter.
32
- *
33
- * Fast - Tries to minimize the number of validates calls to the AI lowering the response times
34
- * for selecting options. Might not always give the expected result for complex products.
35
- *
36
- * Strict - Apply the SyncGroups rules in a stricter fashion to be as close to CET as possible,
37
- * which might result in longer response times and more validation calls to the API when
38
- * selecting options.
39
- *
40
- * The SDK will default to Strict, but we recommend that you try out Fast since cases where the
41
- * results differ should be rare in most real uses cases and the speedup can be quite large.
42
- */
43
- syncGroupsApplyMode: SyncGroupsApplyMode | undefined;
44
- };
45
- /**
46
- * This enum is used internally in the SDK and is not expected by be used directly by integrators.
47
- */
48
- export declare enum CfgProductBubbleMode {
49
- /** Stop bubbling. */
50
- Stop = "Stop",
51
- /**
52
- * Bubble to the parent CfgProduct up the tree.
53
- * This makes the CfgProduct we we call from notify that it has changed, and the CfgProduct
54
- * above switch out the reference to this.
55
- */
56
- OneLevel = "OneLevel",
57
- /** Bubble to the root CfgProduct. */
58
- ToRoot = "ToRoot",
59
- /** Bubble to the root CfgProduct and turn on all optional CfgProducts on the way up. */
60
- ToRootAndBubbleSelected = "ToRootAndBubbleSelected"
61
- }
62
- export declare type CfgPrice = {
63
- basePrice: number;
64
- listPrice: number;
65
- currency: string;
66
- fractionDigits: number;
67
- };
68
- /**
69
- * This class is meant to only be used through CfgProduct. It should never be instantiated on its
70
- * own. Normally the internal state of this class should never be directly modified. CfgProduct is
71
- * the class that should be used and interacted with.
72
- */
73
- export declare class _CfgProductInternal {
74
- readonly _productLoaderRaw: ProductLoader;
75
- readonly prodParams: DtoProductParamsWithLang;
76
- readonly settings: CfgProductSettings;
77
- readonly uuid: string;
78
- private readonly _rawUnit;
79
- private _rawProductData;
80
- readonly loadingObservable: AggregatedLoadingObservable;
81
- readonly parent: _CfgProductInternal | undefined;
82
- private _additionalProductRef;
83
- private readonly _syncGroupHandler;
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>;
85
- private constructor();
86
- readonly root: _CfgProductInternal;
87
- private _destroyed;
88
- readonly key: string;
89
- readonly additionalProducts: CfgProduct[];
90
- private _selected;
91
- private _configuration;
92
- readonly changeObservable: Observable<CfgProductChangeNotification>;
93
- get selected(): boolean;
94
- readonly isAdditionalProduct: boolean;
95
- clone(parent?: _CfgProductInternal, root?: _CfgProductInternal): Promise<_CfgProductInternal>;
96
- destroy: () => void;
97
- _updateAdditionalProdRef(p: DtoAdditionalProductRef): void;
98
- get description(): string | undefined;
99
- get rootNodeSources(): RootNodeSource[] | undefined;
100
- get mtrlApplications(): DtoMtrlApplication[] | undefined;
101
- get currency(): string;
102
- get fractionDigits(): number;
103
- get prices(): DtoPrices | undefined;
104
- private _measureDefinitions;
105
- get measureDefinitions(): CfgMeasureDefinition[];
106
- private _unit;
107
- get refKey(): string | undefined;
108
- get transform(): DtoTransform | undefined;
109
- get anchor(): DtoMeasureParam | undefined;
110
- /** @throws an error if the actual unit sent by the server was not a LengthUnit */
111
- get unit(): LengthUnit;
112
- get aggregatedPrice(): CfgPrice;
113
- get optional(): boolean;
114
- setSelected(v: boolean, bubbleMode: CfgProductBubbleMode): Promise<boolean>;
115
- get configuration(): CfgProductConfiguration;
116
- get rawProductData(): CfgProductData;
117
- /**
118
- * Please note that this relates to the visibility in the Configuration tree.
119
- * It does not affect the visibility of anything in the 3D view at all.
120
- */
121
- get visibleIfAdditionalProduct(): boolean;
122
- /**
123
- * Please note that this relates to the visibility in the Configuration tree.
124
- * It does not affect the visibility of anything in the 3D view at all.
125
- */
126
- get visibleIfMainProduct(): boolean;
127
- /**
128
- * Please note that this relates to the visibility in the Configuration tree.
129
- * It does not affect the visibility of anything in the 3D view at all.
130
- */
131
- get visible(): boolean;
132
- _notifyAllOfChange: (bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
133
- /** Called when a child (additional product or the configuration) has changed. */
134
- private _childHasChanged;
135
- /** Called by child to tell its parent that it has changed. */
136
- _additionalProductHasChanged: (freshRef: CfgProduct, bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
137
- /** Called by the configuration to tell its parent that it has changed. */
138
- _configurationHasChanged: (freshRef: CfgProductConfiguration, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
139
- getDtoConf: (includeExtendedData: boolean, includeProductParams: boolean) => DtoProductConfiguration;
140
- setDtoConf: (s: DtoProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
141
- setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
142
- copyFrom: (source: _CfgProductInternal, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
143
- private _setApiSelectionWithOtherProduct;
144
- get syncGroupHandler(): SyncGroupsHandler | undefined;
145
- get syncGroupsVerboseLogging(): boolean;
146
- /**
147
- * Set to true to get verbose sync state changes logged to the console.
148
- */
149
- set syncGroupsVerboseLogging(v: boolean);
150
- structureCompare: (other: _CfgProductInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
151
- tryMatchSelection: (other: _CfgProductInternal, descriptionMatch?: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
152
- /** Only features in selected options and selected additional products. */
153
- _getDescendantFeaturesWithCode: (code: string) => _CfgFeatureInternal[];
154
- private _revalidateInProgressToken;
155
- /**
156
- * Do a validate call for this product. It does not validate additional products, only this
157
- * product in isolation. The validation result is applied on the configuration. Then additional
158
- * products are synced (unloaded, loaded etc.) Finally the changes bubble up the tree.
159
- */
160
- _revalidate: (bubbleMode: CfgProductBubbleMode, productLoader: ProductLoader, committed: boolean) => Promise<boolean>;
161
- /**
162
- * Based on this configuration find what additional products should be shown and not, unload
163
- * (i.e. destroy) those that should no longer be shown, load the new ones.
164
- */
165
- _syncAndLoadAdditionalProducts: (productLoaderForGroupedLoad: ProductLoader) => Promise<boolean>;
166
- }
167
- export declare class CfgProduct {
168
- readonly _internal: _CfgProductInternal;
169
- static make(productLoader: ProductLoader, prodParams: DtoProductParamsWithLang, settings?: Partial<CfgProductSettings>): Promise<CfgProduct>;
170
- /**
171
- * Makes an object wrapping the passed object. This is not a clone method, it is a method to
172
- * make a new outer reference. Like a shallow copy. We use this to help frameworks that are
173
- * build around using equals to detect change.
174
- */
175
- static _makeNewRefFrom(source: _CfgProductInternal): CfgProduct;
176
- private constructor();
177
- isBackedBySame: (other: CfgProduct) => boolean;
178
- /**
179
- * Recursively marks this and descendants as destroyed so that late events are ignored
180
- * correctly. If you destroy one shallow copy of this you destroy all.
181
- */
182
- destroy: () => void;
183
- /** Makes a clone of this. It is disconnected from the original. */
184
- clone: () => Promise<CfgProduct>;
185
- /**
186
- * A client side only key that should uniquely identify this product amongst other additional
187
- * products.
188
- */
189
- get key(): string;
190
- /**
191
- * Only used when this product is in additional product.
192
- * As a product can have multiple instances of the same additional product this key exists.
193
- * It will be unique amongst child products, but not globally unique.
194
- */
195
- get refKey(): string | undefined;
196
- get prodParams(): DtoProductParamsWithLang;
197
- get lang(): string;
198
- get catId(): DtoCatalogueParams;
199
- get partNumber(): string;
200
- get isAdditionalProduct(): boolean;
201
- /** Only used when this product is an additional product. Root products are never optional. */
202
- get optional(): boolean;
203
- /**
204
- * Only applicable when this product is optional. If this product is not optional this is
205
- * always true.
206
- */
207
- get selected(): boolean;
208
- /**
209
- * Please note that this relates to the visibility in the Configuration tree.
210
- * It does not affect the visibility of anything in the 3D view at all.
211
- * Visibility is affects the Configuration for this Product, but any Additional Products
212
- * will not be affected.
213
- */
214
- get visible(): boolean;
215
- /**
216
- * Only applicable when this product is optional.
217
- * Setting this does not cause a validation call as toggling an optional additional product is
218
- * assumed to always be legal.
219
- */
220
- setSelected: (v: boolean) => Promise<boolean>;
221
- get rawProductData(): CfgProductData;
222
- get uuid(): string;
223
- get unit(): LengthUnit;
224
- get sku(): string;
225
- get styleNr(): string;
226
- /** An URL. */
227
- get preview(): string | undefined;
228
- get description(): string | undefined;
229
- get additionalProducts(): CfgProduct[];
230
- get configuration(): CfgProductConfiguration;
231
- get transform(): DtoTransform | undefined;
232
- get currency(): string;
233
- /**
234
- * If positive the number of fraction digits.
235
- * If negative rounding (essentially the number of zeros to the right)
236
- */
237
- get fractionDigits(): number;
238
- get aggregatedPrice(): CfgPrice;
239
- /**
240
- * Experimental. Additional products lacks descriptions or keys that are suitably for structure
241
- * compare, so we use strict-order when trying to match the additional products. This makes
242
- * this method work nicely for different products having pretty much the same child products.
243
- */
244
- structureCompare: (other: CfgProduct, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
245
- /**
246
- * Experimental. Additional products lacks descriptions or keys that are suitably for try
247
- * match, so we use strict-order when trying to match the additional products. This makes
248
- * this method work nicely for different products having pretty much the same child products.
249
- * This method does not propagate its selections.
250
- * This method will cause validation calls if something change.
251
- */
252
- tryMatchSelection: (other: CfgProduct, descriptionMatch?: boolean) => Promise<boolean>;
253
- /**
254
- * Gets what selections has been made on the product, recursively including product
255
- * configuration, optional products and additional products. Used when a full view of all
256
- * selections on a product is needed, such as when doing Render or Export.
257
- */
258
- getApiSelection: () => DtoAdditionalProductConfiguration;
259
- getDtoConf: (includeExtendedData?: boolean, includeProductParams?: boolean) => DtoProductConfiguration;
260
- setDtoConf: (s: DtoProductConfiguration, doValidate?: boolean) => Promise<boolean>;
261
- setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate?: boolean) => Promise<boolean>;
262
- listenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
263
- stopListenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
264
- stopAllListenForChange: () => void;
265
- listenForLoading: (l: SingleArgCallback<boolean>) => void;
266
- stopListenForLoading: (l: SingleArgCallback<boolean>) => void;
267
- stopAllListenForLoading: () => void;
268
- }
1
+ import { AggregatedLoadingObservable, LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
+ import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParamsWithCid, DtoMeasureParam, DtoMiscFile, DtoMtrlApplication, DtoNote, DtoPrices, DtoProductConf, DtoProductParamsWithCidAndLang, DtoTransform } from "./CatalogueAPI.js";
3
+ import { CfgMeasureDefinition } from "./CfgMeasure.js";
4
+ import { CfgProdConfParts } from "./index.js";
5
+ import { _CfgFeatureInternal } from "./productConfiguration/CfgFeature.js";
6
+ import { ProductConfigurationBubbleMode } from "./productConfiguration/CfgOption.js";
7
+ import { CfgProductConfiguration } from "./productConfiguration/CfgProductConfiguration.js";
8
+ import { ProductLoader } from "./productLoader.js";
9
+ import { SyncGroupsApplyMode } from "./syncGroups/SyncGroupsApplyMode.js";
10
+ import { SyncGroupsHandler } from "./syncGroups/SyncGroupsHandler.js";
11
+ import { CfgProductData, RootNodeSource } from "./utilitiesCatalogueData.js";
12
+ /**
13
+ * @freshRef a new pointer to the same product, backed by the same original object
14
+ * @committed false is an indication that this is a potentially transient state. It could
15
+ * be the expected outcome of a SyncGroups transaction, or dragging to stretch a Product.
16
+ * Uncommitted notifications can be used to update for instance spinners, but should not
17
+ * be sent to server or such.
18
+ */
19
+ export declare type CfgProductChangeNotification = {
20
+ freshRef: CfgProduct;
21
+ committed: boolean;
22
+ };
23
+ export declare type CfgProductSettings = {
24
+ /**
25
+ * In a correctly setup catalogue a select-one Feature (i.e. neither optional nor multiple)
26
+ * must have exactly one Option set at a time. However, this is not enforced in Catalogue
27
+ * Creator and it is not uncommon with catalogues which fails to meet this requirement.
28
+ * Activating this will make setApi throw an Error if more or less than one is selected.
29
+ */
30
+ strictSelectOneSelectionCount: boolean;
31
+ /**
32
+ * Controls if SyncGroups are applied Faster or Stricter.
33
+ *
34
+ * Fast - Tries to minimize the number of validates calls to the AI lowering the response times
35
+ * for selecting options. Might not always give the expected result for complex products.
36
+ *
37
+ * Strict - Apply the SyncGroups rules in a stricter fashion to be as close to CET as possible,
38
+ * which might result in longer response times and more validation calls to the API when
39
+ * selecting options.
40
+ *
41
+ * The SDK will default to Strict, but we recommend that you try out Fast since cases where the
42
+ * results differ should be rare in most real uses cases and the speedup can be quite large.
43
+ */
44
+ syncGroupsApplyMode: SyncGroupsApplyMode | undefined;
45
+ };
46
+ /**
47
+ * This enum is used internally in the SDK and is not expected by be used directly by integrators.
48
+ */
49
+ export declare enum CfgProductBubbleMode {
50
+ /** Stop bubbling. */
51
+ Stop = "Stop",
52
+ /**
53
+ * Bubble to the parent CfgProduct up the tree.
54
+ * This makes the CfgProduct we we call from notify that it has changed, and the CfgProduct
55
+ * above switch out the reference to this.
56
+ */
57
+ OneLevel = "OneLevel",
58
+ /** Bubble to the root CfgProduct. */
59
+ ToRoot = "ToRoot",
60
+ /** Bubble to the root CfgProduct and turn on all optional CfgProducts on the way up. */
61
+ ToRootAndBubbleSelected = "ToRootAndBubbleSelected"
62
+ }
63
+ export declare type CfgPrice = {
64
+ basePrice: number;
65
+ listPrice: number;
66
+ currency: string;
67
+ fractionDigits: number;
68
+ };
69
+ /**
70
+ * This class is meant to only be used through CfgProduct. It should never be instantiated on its
71
+ * own. Normally the internal state of this class should never be directly modified. CfgProduct is
72
+ * the class that should be used and interacted with.
73
+ */
74
+ export declare class _CfgProductInternal {
75
+ readonly _productLoaderRaw: ProductLoader;
76
+ readonly prodParams: DtoProductParamsWithCidAndLang;
77
+ readonly settings: CfgProductSettings;
78
+ readonly uuid: string;
79
+ private readonly _rawUnit;
80
+ private _rawProductData;
81
+ readonly loadingObservable: AggregatedLoadingObservable;
82
+ readonly parent: _CfgProductInternal | undefined;
83
+ private _additionalProductRef;
84
+ private readonly _syncGroupHandler;
85
+ static make: (productLoaderRaw: ProductLoader, productLoaderForGroupedLoad: ProductLoader | undefined, prodParams: DtoProductParamsWithCidAndLang, settings: CfgProductSettings, optional: boolean, loadingObservable: AggregatedLoadingObservable, parent: _CfgProductInternal | undefined, root: _CfgProductInternal | undefined, additionalProductRef: DtoAdditionalProductRef | undefined, initialProductConfiguration: DtoProductConf | DtoAdditionalProductConfiguration | undefined) => Promise<_CfgProductInternal>;
86
+ _initialClone: _CfgProductInternal | undefined;
87
+ private constructor();
88
+ readonly root: _CfgProductInternal;
89
+ private _destroyed;
90
+ readonly key: string;
91
+ readonly additionalProducts: CfgProduct[];
92
+ private _selected;
93
+ private _configuration;
94
+ private _notes;
95
+ readonly changeObservable: Observable<CfgProductChangeNotification>;
96
+ get selected(): boolean;
97
+ readonly isAdditionalProduct: boolean;
98
+ /**
99
+ * Please note that cloning an additional product will make the clone believe is is
100
+ * an additional product, even if it has no parent and root.
101
+ * Providing the parent and root of what you clone as arguments is unwise as it will
102
+ * make changes you do on the clone be propagated up to the original non-clone root product.
103
+ */
104
+ clone(parent?: _CfgProductInternal, root?: _CfgProductInternal): Promise<_CfgProductInternal>;
105
+ /** Mark this and its descendants as destroyed and remove all listeners */
106
+ destroy: () => void;
107
+ /**
108
+ * Reset will reset the product to its initial state
109
+ */
110
+ reset: () => Promise<void>;
111
+ /**
112
+ * Internal use. Used when this product is an additional product, and
113
+ * changing a parent product has made the settings for this product
114
+ * change.
115
+ */
116
+ _updateAdditionalProdRef(p: DtoAdditionalProductRef): void;
117
+ /**
118
+ * Return a DtoNode using noteRef as a key.
119
+ * Throws an error if no note is found.
120
+ */
121
+ getNote(noteRef: string): DtoNote;
122
+ /**
123
+ * noteRefs is a list of keys coming from CfgOption, CfgFeature or CfgProduct.
124
+ * The keys are used to get a DtoNote[] from notes at CfgProduct.
125
+ */
126
+ getNotes(noteRefs: string[]): DtoNote[];
127
+ private addNotes;
128
+ get notes(): DtoNote[];
129
+ get miscFiles(): DtoMiscFile[];
130
+ get hasRootFeaturesChanged(): boolean;
131
+ get description(): string | undefined;
132
+ get rootNodeSources(): RootNodeSource[] | undefined;
133
+ get mtrlApplications(): DtoMtrlApplication[] | undefined;
134
+ get currency(): string;
135
+ get fractionDigits(): number;
136
+ get prices(): DtoPrices | undefined;
137
+ private _measureDefinitions;
138
+ get measureDefinitions(): CfgMeasureDefinition[];
139
+ private _unit;
140
+ get refKey(): string | undefined;
141
+ get transform(): DtoTransform | undefined;
142
+ get anchor(): DtoMeasureParam | undefined;
143
+ /** @throws an error if the actual unit sent by the server was not a LengthUnit */
144
+ get unit(): LengthUnit;
145
+ get aggregatedPrice(): CfgPrice;
146
+ get optional(): boolean;
147
+ setSelected(selected: boolean, bubbleMode: CfgProductBubbleMode, interactive: boolean): Promise<boolean>;
148
+ get configuration(): CfgProductConfiguration;
149
+ get rawProductData(): CfgProductData;
150
+ /**
151
+ * Please note that this relates to the visibility in the Configuration tree.
152
+ * It does not affect the visibility of anything in the 3D view at all.
153
+ */
154
+ get visibleIfAdditionalProduct(): boolean;
155
+ /**
156
+ * Please note that this relates to the visibility in the Configuration tree.
157
+ * It does not affect the visibility of anything in the 3D view at all.
158
+ */
159
+ get visibleIfMainProduct(): boolean;
160
+ /**
161
+ * Please note that this relates to the visibility in the Configuration tree.
162
+ * It does not affect the visibility of anything in the 3D view at all.
163
+ */
164
+ get visible(): boolean;
165
+ _notifyAllOfChange: (bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
166
+ /** Called when a child (additional product or the configuration) has changed. */
167
+ private _childHasChanged;
168
+ /** Called by child to tell its parent that it has changed. */
169
+ _additionalProductHasChanged: (freshRef: CfgProduct, bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
170
+ /** Called by the configuration to tell its parent that it has changed. */
171
+ _configurationHasChanged: (freshRef: CfgProductConfiguration, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
172
+ getDtoConf: (include: CfgProdConfParts) => DtoProductConf;
173
+ setDtoConf: (s: DtoProductConf, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
174
+ setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
175
+ copyFrom: (source: _CfgProductInternal, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
176
+ private _setApiSelectionWithOtherProduct;
177
+ get syncGroupHandler(): SyncGroupsHandler | undefined;
178
+ get syncGroupsVerboseLogging(): boolean;
179
+ /**
180
+ * Set to true to get verbose sync state changes logged to the console.
181
+ */
182
+ set syncGroupsVerboseLogging(v: boolean);
183
+ structureCompare: (other: _CfgProductInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
184
+ tryMatchSelection: (other: _CfgProductInternal, descriptionMatch?: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
185
+ /** Only features in selected options and selected additional products. */
186
+ _getDescendantFeaturesWithCode: (code: string) => _CfgFeatureInternal[];
187
+ private _revalidateInProgressToken;
188
+ /**
189
+ * Do a validate call for this product. It does not validate additional products, only this
190
+ * product in isolation. The validation result is applied on the configuration. Then additional
191
+ * products are synced (unloaded, loaded etc.) Finally the changes bubble up the tree.
192
+ */
193
+ _revalidate: (bubbleMode: CfgProductBubbleMode, productLoader: ProductLoader, committed: boolean) => Promise<boolean>;
194
+ /**
195
+ * Based on this configuration find what additional products should be shown and not, unload
196
+ * (i.e. destroy) those that should no longer be shown, load the new ones.
197
+ */
198
+ _syncAndLoadAdditionalProducts: (productLoaderForGroupedLoad: ProductLoader, initialProductConfiguration: DtoAdditionalProductConfiguration | undefined) => Promise<boolean>;
199
+ }
200
+ export declare class CfgProduct {
201
+ readonly _internal: _CfgProductInternal;
202
+ static make(productLoader: ProductLoader, prodParams: DtoProductParamsWithCidAndLang, settings?: Partial<CfgProductSettings>, initialProductConfiguration?: DtoProductConf | DtoAdditionalProductConfiguration): Promise<CfgProduct>;
203
+ /**
204
+ * Makes an object wrapping the passed object. This is not a clone method, it is a method to
205
+ * make a new outer reference. Like a shallow copy. We use this to help frameworks that are
206
+ * build around using equals to detect change.
207
+ */
208
+ static _makeNewRefFrom(source: _CfgProductInternal): CfgProduct;
209
+ private constructor();
210
+ isBackedBySame: (other: CfgProduct) => boolean;
211
+ /**
212
+ * Recursively marks this and descendants as destroyed so that late events are ignored
213
+ * correctly. If you destroy one shallow copy of this you destroy all.
214
+ */
215
+ destroy: () => void;
216
+ /** Makes a clone of this. It is disconnected from the original. */
217
+ clone: () => Promise<CfgProduct>;
218
+ /**
219
+ * A client side only key that should uniquely identify this product amongst other additional
220
+ * products.
221
+ */
222
+ get key(): string;
223
+ /**
224
+ * Only used when this product is in additional product.
225
+ * As a product can have multiple instances of the same additional product this key exists.
226
+ * It will be unique amongst child products, but not globally unique.
227
+ */
228
+ get refKey(): string | undefined;
229
+ get notes(): DtoNote[];
230
+ get miscFiles(): DtoMiscFile[];
231
+ get prodParams(): DtoProductParamsWithCidAndLang;
232
+ get lang(): string;
233
+ get catId(): DtoCatalogueParamsWithCid;
234
+ get partNumber(): string;
235
+ get isAdditionalProduct(): boolean;
236
+ /** Only used when this product is an additional product. Root products are never optional. */
237
+ get optional(): boolean;
238
+ /**
239
+ * Only applicable when this product is optional. If this product is not optional this is
240
+ * always true.
241
+ */
242
+ get selected(): boolean;
243
+ /**
244
+ * Please note that this relates to the visibility in the Configuration tree.
245
+ * It does not affect the visibility of anything in the 3D view at all.
246
+ * Visibility affects the Configuration for this Product, but any Additional Products
247
+ * will not be affected.
248
+ */
249
+ get visible(): boolean;
250
+ /**
251
+ * Only applicable when this product is optional.
252
+ * Setting this does not cause a validation call as toggling an optional additional product is
253
+ * assumed to always be legal.
254
+ */
255
+ setSelected: (v: boolean) => Promise<boolean>;
256
+ /**
257
+ * Functional selection is a Catalogues feature where selecting Options on Features result in that you
258
+ * "jump" to another Product as a result of the Validate call. You normally do not notice that a functional
259
+ * selection has occurred except for the styleNr changing. Functional selection can change which Features
260
+ * from the original product call are used as root Features. This can in turn affect if serialized
261
+ * configuration can be applied or not.
262
+ *
263
+ * The SDK can currently only apply serialized configuration if the list of root Features has not changed.
264
+ * For this reason, when functional selection has happened, extracting data for external systems might work
265
+ * well, but reapplying back into Stage will probably fail.
266
+ */
267
+ get hasRootFeaturesChanged(): boolean;
268
+ get rawProductData(): CfgProductData;
269
+ get uuid(): string;
270
+ get unit(): LengthUnit;
271
+ get sku(): string;
272
+ get styleNr(): string;
273
+ /** An URL. */
274
+ get preview(): string | undefined;
275
+ get description(): string | undefined;
276
+ get additionalProducts(): CfgProduct[];
277
+ get configuration(): CfgProductConfiguration;
278
+ get transform(): DtoTransform | undefined;
279
+ get currency(): string;
280
+ /**
281
+ * If positive the number of fraction digits.
282
+ * If negative rounding (essentially the number of zeros to the right)
283
+ */
284
+ get fractionDigits(): number;
285
+ get aggregatedPrice(): CfgPrice;
286
+ /**
287
+ * Experimental. Additional products lacks descriptions or keys that are suitably for structure
288
+ * compare, so we use strict-order when trying to match the additional products. This makes
289
+ * this method work nicely for different products having pretty much the same child products.
290
+ */
291
+ structureCompare: (other: CfgProduct, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
292
+ /**
293
+ * Experimental. Additional products lacks descriptions or keys that are suitably for try
294
+ * match, so we use strict-order when trying to match the additional products. This makes
295
+ * this method work nicely for different products having pretty much the same child products.
296
+ * This method does not propagate its selections.
297
+ * This method will cause validation calls if something change.
298
+ */
299
+ tryMatchSelection: (other: CfgProduct, descriptionMatch?: boolean) => Promise<boolean>;
300
+ /**
301
+ * Gets what selections has been made on the product, recursively including product
302
+ * configuration, optional products and additional products. Used when a full view of all
303
+ * selections on a product is needed, such as when doing Render or Export.
304
+ * @deprecated getDtoConf provides a newer format.
305
+ * @see getDtoConf
306
+ */
307
+ getApiSelection: () => DtoAdditionalProductConfiguration;
308
+ /**
309
+ * Applies the configuration (selections) in the passed object onto the product recursively
310
+ * including product configuration, optional products and additional products.
311
+ * @param doValidate Makes a server side validation call. These are necessary to ensure that
312
+ * the right models are loaded.
313
+ * @deprecated setDtoConf uses a newer format.
314
+ */
315
+ setApiSelection: (configuration: DtoAdditionalProductConfiguration, doValidate?: boolean) => Promise<boolean>;
316
+ /**
317
+ * A newer alternative version of getApiSelection. This returns the configuration (selections)
318
+ * on the product, recursively including product configuration, optional products and additional
319
+ * products.
320
+ * This version has the following advantages over getApiSelection:
321
+ * - The format is clearer, designed to be readable
322
+ * - Makes less assumptions about the structure in the Product being unchanging over time. In
323
+ * particular, the Feature codes are included in the data, so that changes to what Features
324
+ * are used in a Product is less likely to lead to unexpected results.
325
+ * - You can request ExtendedData, ProductParams and/or SyncGroupState to be included in the
326
+ * result. This extra data is ignored when passed back into the API, but it can be very useful
327
+ * for external applications.
328
+ * The other version (getApiSelection) has the advantage of using a format directly compatible with the API:s.
329
+ * @param include Includes extra data which is not an actual part of the configuration
330
+ */
331
+ getDtoConf: (include?: CfgProdConfParts) => DtoProductConf;
332
+ /**
333
+ * A newer alternative version of setApiSelection.
334
+ * @param doValidate Makes a server side validation call. These are necessary to ensure that
335
+ * the right models are loaded.
336
+ */
337
+ setDtoConf: (configuration: DtoProductConf, doValidate?: boolean) => Promise<boolean>;
338
+ listenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
339
+ stopListenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
340
+ stopAllListenForChange: () => void;
341
+ listenForLoading: (l: SingleArgCallback<boolean>) => void;
342
+ stopListenForLoading: (l: SingleArgCallback<boolean>) => void;
343
+ stopAllListenForLoading: () => void;
344
+ }
269
345
  //# sourceMappingURL=CfgProduct.d.ts.map