@configura/web-api 2.0.0-alpha.21 → 2.0.0-alpha.22

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 -5
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/CatalogueAPI.d.ts +622 -597
  5. package/dist/CatalogueAPI.js +329 -328
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +344 -328
  9. package/dist/CfgProduct.js +996 -934
  10. package/dist/CfgReferencePathHelper.d.ts +26 -26
  11. package/dist/CfgReferencePathHelper.js +26 -26
  12. package/dist/ConfigurationConverter.d.ts +17 -17
  13. package/dist/ConfigurationConverter.js +175 -175
  14. package/dist/index.d.ts +23 -23
  15. package/dist/index.js +23 -23
  16. package/dist/io/CfgHistoryManager.d.ts +83 -83
  17. package/dist/io/CfgHistoryManager.js +144 -144
  18. package/dist/io/CfgHistoryToProdConfConnector.d.ts +21 -21
  19. package/dist/io/CfgHistoryToProdConfConnector.js +50 -50
  20. package/dist/io/CfgIOManager.d.ts +53 -53
  21. package/dist/io/CfgIOManager.js +134 -134
  22. package/dist/io/CfgIOProdConfConnector.d.ts +64 -64
  23. package/dist/io/CfgIOProdConfConnector.js +149 -149
  24. package/dist/io/CfgIOWarningSupplier.d.ts +3 -3
  25. package/dist/io/CfgIOWarningSupplier.js +1 -1
  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 -14
  29. package/dist/io/CfgObservableStateToProdConfConnector.js +16 -16
  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 -91
  34. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +16 -16
  35. package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -18
  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 +193 -189
  49. package/dist/productConfiguration/CfgFeature.js +671 -658
  50. package/dist/productConfiguration/CfgOption.d.ts +156 -151
  51. package/dist/productConfiguration/CfgOption.js +439 -422
  52. package/dist/productConfiguration/CfgProductConfiguration.d.ts +129 -129
  53. package/dist/productConfiguration/CfgProductConfiguration.js +340 -340
  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 -87
  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 -47
  65. package/dist/syncGroups/SyncGroupsHandler.js +370 -370
  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 -39
  69. package/dist/syncGroups/SyncGroupsState.js +167 -167
  70. package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
  71. package/dist/syncGroups/SyncGroupsTransaction.js +589 -589
  72. package/dist/tasks/TaskHandler.d.ts +77 -77
  73. package/dist/tasks/TaskHandler.js +276 -276
  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 -282
  82. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  83. package/dist/tests/testData/testDataCachedGetProduct.js +187 -187
  84. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  85. package/dist/tests/testData/testDataCachedPostValidate.js +185 -185
  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 -189
  92. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  93. package/dist/tests/testData/testDataUpcharge.js +121 -121
  94. package/dist/utilitiesCatalogueData.d.ts +47 -47
  95. package/dist/utilitiesCatalogueData.js +180 -180
  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 -114
  100. package/package.json +3 -3
@@ -1,329 +1,345 @@
1
- import { AggregatedLoadingObservable, LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParamsWithCid, DtoMeasureParam, DtoMtrlApplication, 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
- readonly changeObservable: Observable<CfgProductChangeNotification>;
95
- get selected(): boolean;
96
- readonly isAdditionalProduct: boolean;
97
- /**
98
- * Please note that cloning an additional product will make the clone believe is is
99
- * an additional product, even if it has no parent and root.
100
- * Providing the parent and root of what you clone as arguments is unwise as it will
101
- * make changes you do on the clone be propagated up to the original non-clone root product.
102
- */
103
- clone(parent?: _CfgProductInternal, root?: _CfgProductInternal): Promise<_CfgProductInternal>;
104
- /** Mark this and its descendants as destroyed and remove all listeners */
105
- destroy: () => void;
106
- /**
107
- * Reset will reset the product to its initial state
108
- */
109
- reset: () => Promise<void>;
110
- /**
111
- * Internal use. Used when this product is an additional product, and
112
- * changing a parent product has made the settings for this product
113
- * change.
114
- */
115
- _updateAdditionalProdRef(p: DtoAdditionalProductRef): void;
116
- get hasRootFeaturesChanged(): boolean;
117
- get description(): string | undefined;
118
- get rootNodeSources(): RootNodeSource[] | undefined;
119
- get mtrlApplications(): DtoMtrlApplication[] | undefined;
120
- get currency(): string;
121
- get fractionDigits(): number;
122
- get prices(): DtoPrices | undefined;
123
- private _measureDefinitions;
124
- get measureDefinitions(): CfgMeasureDefinition[];
125
- private _unit;
126
- get refKey(): string | undefined;
127
- get transform(): DtoTransform | undefined;
128
- get anchor(): DtoMeasureParam | undefined;
129
- /** @throws an error if the actual unit sent by the server was not a LengthUnit */
130
- get unit(): LengthUnit;
131
- get aggregatedPrice(): CfgPrice;
132
- get optional(): boolean;
133
- setSelected(selected: boolean, bubbleMode: CfgProductBubbleMode, interactive: boolean): Promise<boolean>;
134
- get configuration(): CfgProductConfiguration;
135
- get rawProductData(): CfgProductData;
136
- /**
137
- * Please note that this relates to the visibility in the Configuration tree.
138
- * It does not affect the visibility of anything in the 3D view at all.
139
- */
140
- get visibleIfAdditionalProduct(): boolean;
141
- /**
142
- * Please note that this relates to the visibility in the Configuration tree.
143
- * It does not affect the visibility of anything in the 3D view at all.
144
- */
145
- get visibleIfMainProduct(): boolean;
146
- /**
147
- * Please note that this relates to the visibility in the Configuration tree.
148
- * It does not affect the visibility of anything in the 3D view at all.
149
- */
150
- get visible(): boolean;
151
- _notifyAllOfChange: (bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
152
- /** Called when a child (additional product or the configuration) has changed. */
153
- private _childHasChanged;
154
- /** Called by child to tell its parent that it has changed. */
155
- _additionalProductHasChanged: (freshRef: CfgProduct, bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
156
- /** Called by the configuration to tell its parent that it has changed. */
157
- _configurationHasChanged: (freshRef: CfgProductConfiguration, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
158
- getDtoConf: (include: CfgProdConfParts) => DtoProductConf;
159
- setDtoConf: (s: DtoProductConf, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
160
- setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
161
- copyFrom: (source: _CfgProductInternal, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
162
- private _setApiSelectionWithOtherProduct;
163
- get syncGroupHandler(): SyncGroupsHandler | undefined;
164
- get syncGroupsVerboseLogging(): boolean;
165
- /**
166
- * Set to true to get verbose sync state changes logged to the console.
167
- */
168
- set syncGroupsVerboseLogging(v: boolean);
169
- structureCompare: (other: _CfgProductInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
170
- tryMatchSelection: (other: _CfgProductInternal, descriptionMatch?: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
171
- /** Only features in selected options and selected additional products. */
172
- _getDescendantFeaturesWithCode: (code: string) => _CfgFeatureInternal[];
173
- private _revalidateInProgressToken;
174
- /**
175
- * Do a validate call for this product. It does not validate additional products, only this
176
- * product in isolation. The validation result is applied on the configuration. Then additional
177
- * products are synced (unloaded, loaded etc.) Finally the changes bubble up the tree.
178
- */
179
- _revalidate: (bubbleMode: CfgProductBubbleMode, productLoader: ProductLoader, committed: boolean) => Promise<boolean>;
180
- /**
181
- * Based on this configuration find what additional products should be shown and not, unload
182
- * (i.e. destroy) those that should no longer be shown, load the new ones.
183
- */
184
- _syncAndLoadAdditionalProducts: (productLoaderForGroupedLoad: ProductLoader, initialProductConfiguration: DtoAdditionalProductConfiguration | undefined) => Promise<boolean>;
185
- }
186
- export declare class CfgProduct {
187
- readonly _internal: _CfgProductInternal;
188
- static make(productLoader: ProductLoader, prodParams: DtoProductParamsWithCidAndLang, settings?: Partial<CfgProductSettings>, initialProductConfiguration?: DtoProductConf | DtoAdditionalProductConfiguration): Promise<CfgProduct>;
189
- /**
190
- * Makes an object wrapping the passed object. This is not a clone method, it is a method to
191
- * make a new outer reference. Like a shallow copy. We use this to help frameworks that are
192
- * build around using equals to detect change.
193
- */
194
- static _makeNewRefFrom(source: _CfgProductInternal): CfgProduct;
195
- private constructor();
196
- isBackedBySame: (other: CfgProduct) => boolean;
197
- /**
198
- * Recursively marks this and descendants as destroyed so that late events are ignored
199
- * correctly. If you destroy one shallow copy of this you destroy all.
200
- */
201
- destroy: () => void;
202
- /** Makes a clone of this. It is disconnected from the original. */
203
- clone: () => Promise<CfgProduct>;
204
- /**
205
- * A client side only key that should uniquely identify this product amongst other additional
206
- * products.
207
- */
208
- get key(): string;
209
- /**
210
- * Only used when this product is in additional product.
211
- * As a product can have multiple instances of the same additional product this key exists.
212
- * It will be unique amongst child products, but not globally unique.
213
- */
214
- get refKey(): string | undefined;
215
- get prodParams(): DtoProductParamsWithCidAndLang;
216
- get lang(): string;
217
- get catId(): DtoCatalogueParamsWithCid;
218
- get partNumber(): string;
219
- get isAdditionalProduct(): boolean;
220
- /** Only used when this product is an additional product. Root products are never optional. */
221
- get optional(): boolean;
222
- /**
223
- * Only applicable when this product is optional. If this product is not optional this is
224
- * always true.
225
- */
226
- get selected(): boolean;
227
- /**
228
- * Please note that this relates to the visibility in the Configuration tree.
229
- * It does not affect the visibility of anything in the 3D view at all.
230
- * Visibility is affects the Configuration for this Product, but any Additional Products
231
- * will not be affected.
232
- */
233
- get visible(): boolean;
234
- /**
235
- * Only applicable when this product is optional.
236
- * Setting this does not cause a validation call as toggling an optional additional product is
237
- * assumed to always be legal.
238
- */
239
- setSelected: (v: boolean) => Promise<boolean>;
240
- /**
241
- * Functional selection is a Catalogues feature where selecting Options on Features result in that you
242
- * "jump" to another Product as a result of the Validate call. You normally do not notice that a functional
243
- * selection has occurred except for the styleNr changing. Functional selection can change which Features
244
- * from the original product call are used as root Features. This can in turn affect if serialized
245
- * configuration can be applied or not.
246
- *
247
- * The SDK can currently only apply serialized configuration if the list of root Features has not changed.
248
- * For this reason, when functional selection has happened, extracting data for external systems might work
249
- * well, but reapplying back into Stage will probably fail.
250
- */
251
- get hasRootFeaturesChanged(): boolean;
252
- get rawProductData(): CfgProductData;
253
- get uuid(): string;
254
- get unit(): LengthUnit;
255
- get sku(): string;
256
- get styleNr(): string;
257
- /** An URL. */
258
- get preview(): string | undefined;
259
- get description(): string | undefined;
260
- get additionalProducts(): CfgProduct[];
261
- get configuration(): CfgProductConfiguration;
262
- get transform(): DtoTransform | undefined;
263
- get currency(): string;
264
- /**
265
- * If positive the number of fraction digits.
266
- * If negative rounding (essentially the number of zeros to the right)
267
- */
268
- get fractionDigits(): number;
269
- get aggregatedPrice(): CfgPrice;
270
- /**
271
- * Experimental. Additional products lacks descriptions or keys that are suitably for structure
272
- * compare, so we use strict-order when trying to match the additional products. This makes
273
- * this method work nicely for different products having pretty much the same child products.
274
- */
275
- structureCompare: (other: CfgProduct, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
276
- /**
277
- * Experimental. Additional products lacks descriptions or keys that are suitably for try
278
- * match, so we use strict-order when trying to match the additional products. This makes
279
- * this method work nicely for different products having pretty much the same child products.
280
- * This method does not propagate its selections.
281
- * This method will cause validation calls if something change.
282
- */
283
- tryMatchSelection: (other: CfgProduct, descriptionMatch?: boolean) => Promise<boolean>;
284
- /**
285
- * Gets what selections has been made on the product, recursively including product
286
- * configuration, optional products and additional products. Used when a full view of all
287
- * selections on a product is needed, such as when doing Render or Export.
288
- * @deprecated getDtoConf provides a newer format.
289
- * @see getDtoConf
290
- */
291
- getApiSelection: () => DtoAdditionalProductConfiguration;
292
- /**
293
- * Applies the configuration (selections) in the passed object onto the product recursively
294
- * including product configuration, optional products and additional products.
295
- * @param doValidate Makes a server side validation call. These are necessary to ensure that
296
- * the right models are loaded.
297
- * @deprecated setDtoConf uses a newer format.
298
- */
299
- setApiSelection: (configuration: DtoAdditionalProductConfiguration, doValidate?: boolean) => Promise<boolean>;
300
- /**
301
- * A newer alternative version of getApiSelection. This returns the configuration (selections)
302
- * on the product, recursively including product configuration, optional products and additional
303
- * products.
304
- * This version has the following advantages over getApiSelection:
305
- * - The format is clearer, designed to be readable
306
- * - Makes less assumptions about the structure in the Product being unchanging over time. In
307
- * particular, the Feature codes are included in the data, so that changes to what Features
308
- * are used in a Product is less likely to lead to unexpected results.
309
- * - You can request ExtendedData, ProductParams and/or SyncGroupState to be included in the
310
- * result. This extra data is ignored when passed back into the API, but it can be very useful
311
- * for external applications.
312
- * The other version (getApiSelection) has the advantage of using a format directly compatible with the API:s.
313
- * @param include Includes extra data which is not an actual part of the configuration
314
- */
315
- getDtoConf: (include?: CfgProdConfParts) => DtoProductConf;
316
- /**
317
- * A newer alternative version of setApiSelection.
318
- * @param doValidate Makes a server side validation call. These are necessary to ensure that
319
- * the right models are loaded.
320
- */
321
- setDtoConf: (configuration: DtoProductConf, doValidate?: boolean) => Promise<boolean>;
322
- listenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
323
- stopListenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
324
- stopAllListenForChange: () => void;
325
- listenForLoading: (l: SingleArgCallback<boolean>) => void;
326
- stopListenForLoading: (l: SingleArgCallback<boolean>) => void;
327
- stopAllListenForLoading: () => void;
328
- }
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
+ }
329
345
  //# sourceMappingURL=CfgProduct.d.ts.map