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

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