@configura/web-api 2.0.0-alpha.0 → 2.0.0-alpha.3

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 (98) hide show
  1. package/.eslintrc.json +18 -18
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/CatalogueAPI.d.ts +551 -551
  5. package/dist/CatalogueAPI.js +293 -293
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +268 -268
  9. package/dist/CfgProduct.js +778 -778
  10. package/dist/CfgReferencePathHelper.d.ts +13 -13
  11. package/dist/CfgReferencePathHelper.js +13 -13
  12. package/dist/ConfigurationConverter.d.ts +4 -4
  13. package/dist/ConfigurationConverter.js +72 -72
  14. package/dist/index.d.ts +23 -23
  15. package/dist/index.js +23 -23
  16. package/dist/io/CfgHistoryManager.d.ts +50 -50
  17. package/dist/io/CfgHistoryManager.js +82 -82
  18. package/dist/io/CfgHistoryToProdConfConnector.d.ts +20 -20
  19. package/dist/io/CfgHistoryToProdConfConnector.js +56 -56
  20. package/dist/io/CfgIOManager.d.ts +48 -48
  21. package/dist/io/CfgIOManager.js +115 -115
  22. package/dist/io/CfgIOProdConfConnector.d.ts +52 -52
  23. package/dist/io/CfgIOProdConfConnector.js +141 -141
  24. package/dist/io/CfgObservableStateManager.d.ts +21 -21
  25. package/dist/io/CfgObservableStateManager.js +65 -65
  26. package/dist/io/CfgObservableStateToProdConfConnector.d.ts +14 -14
  27. package/dist/io/CfgObservableStateToProdConfConnector.js +16 -16
  28. package/dist/io/CfgWindowEventManager.d.ts +21 -21
  29. package/dist/io/CfgWindowEventManager.js +38 -38
  30. package/dist/io/CfgWindowMessageManager.d.ts +40 -40
  31. package/dist/io/CfgWindowMessageManager.js +84 -84
  32. package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +16 -16
  33. package/dist/io/CfgWindowMessageToProdConfConnector.js +18 -18
  34. package/dist/io/index.d.ts +8 -8
  35. package/dist/io/index.js +8 -8
  36. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  37. package/dist/material/CfgMaterialMapping.js +181 -181
  38. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  39. package/dist/material/CfgMtrlApplication.js +43 -43
  40. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  41. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  42. package/dist/material/CfgMtrlSource.d.ts +19 -19
  43. package/dist/material/CfgMtrlSource.js +40 -40
  44. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  45. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  46. package/dist/productConfiguration/CfgFeature.d.ts +187 -187
  47. package/dist/productConfiguration/CfgFeature.js +645 -645
  48. package/dist/productConfiguration/CfgOption.d.ts +151 -151
  49. package/dist/productConfiguration/CfgOption.js +416 -416
  50. package/dist/productConfiguration/CfgProductConfiguration.d.ts +117 -117
  51. package/dist/productConfiguration/CfgProductConfiguration.js +307 -307
  52. package/dist/productConfiguration/filters.d.ts +15 -15
  53. package/dist/productConfiguration/filters.js +70 -70
  54. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  55. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  56. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
  57. package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -80
  58. package/dist/productLoader.d.ts +33 -33
  59. package/dist/productLoader.js +49 -49
  60. package/dist/syncGroups/SyncGroupsApplyMode.d.ts +20 -20
  61. package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
  62. package/dist/syncGroups/SyncGroupsHandler.d.ts +40 -40
  63. package/dist/syncGroups/SyncGroupsHandler.js +359 -359
  64. package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
  65. package/dist/syncGroups/SyncGroupsPathHelper.js +90 -90
  66. package/dist/syncGroups/SyncGroupsState.d.ts +35 -35
  67. package/dist/syncGroups/SyncGroupsState.js +125 -125
  68. package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -154
  69. package/dist/syncGroups/SyncGroupsTransaction.js +576 -576
  70. package/dist/tasks/TaskHandler.d.ts +77 -77
  71. package/dist/tasks/TaskHandler.js +275 -275
  72. package/dist/tasks/formats.d.ts +4 -4
  73. package/dist/tasks/formats.js +7 -7
  74. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  75. package/dist/tests/testData/collectorForTest.js +194 -194
  76. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  77. package/dist/tests/testData/dummyProductForTest.js +32 -32
  78. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -11
  79. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +277 -277
  80. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  81. package/dist/tests/testData/testDataCachedGetProduct.js +185 -185
  82. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  83. package/dist/tests/testData/testDataCachedPostValidate.js +183 -183
  84. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  85. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
  86. package/dist/tests/testData/testDataOptions.d.ts +12 -12
  87. package/dist/tests/testData/testDataOptions.js +60 -60
  88. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
  89. package/dist/tests/testData/testDataProductAggregatedPrice.js +187 -187
  90. package/dist/tests/testData/testDataUpcharge.d.ts +8 -8
  91. package/dist/tests/testData/testDataUpcharge.js +119 -119
  92. package/dist/utilitiesCatalogueData.d.ts +42 -33
  93. package/dist/utilitiesCatalogueData.js +173 -164
  94. package/dist/utilitiesCataloguePermission.d.ts +38 -32
  95. package/dist/utilitiesCataloguePermission.js +79 -76
  96. package/dist/utilitiesNumericValues.d.ts +24 -24
  97. package/dist/utilitiesNumericValues.js +109 -109
  98. package/package.json +3 -3
@@ -1,30 +1,30 @@
1
- /**
2
- * This class strips the Measurement of things that are not actually used or relevant
3
- * to Stage, specifically anchoring and stretching. Measurements can also contain
4
- * volume and area, but these are ignored. Here Measures are used to define defaults
5
- * such as its preferences when dealing with ambiguity or its default value.
6
- */
7
- export class CfgMeasureDefinition {
8
- constructor(measureParamCode, numericValue, measurePriorities) {
9
- this.measureParamCode = measureParamCode;
10
- this.numericValue = numericValue;
11
- this.measurePriorities = measurePriorities;
12
- }
13
- static make(measurement) {
14
- // The measurement.code seems to be used in CET to connect the value to
15
- // pre-existing fields in the product, such as width, height and depth.
16
- // We however only use this for anchoring and stretching and so it is the
17
- // code of the measureParam that is relevant. Hence Measurements with no
18
- // measureParam are ignored.
19
- var _a;
20
- const measureParam = measurement.measureParam;
21
- if (measureParam === undefined) {
22
- return undefined;
23
- }
24
- const code = measureParam.code;
25
- return new this(code, measurement.numericValue, ((_a = measureParam.measurePriority) !== null && _a !== void 0 ? _a : []).map((p, index) => ({
26
- modelLocalFilePath: p.url,
27
- index,
28
- })));
29
- }
30
- }
1
+ /**
2
+ * This class strips the Measurement of things that are not actually used or relevant
3
+ * to Stage, specifically anchoring and stretching. Measurements can also contain
4
+ * volume and area, but these are ignored. Here Measures are used to define defaults
5
+ * such as its preferences when dealing with ambiguity or its default value.
6
+ */
7
+ export class CfgMeasureDefinition {
8
+ constructor(measureParamCode, numericValue, measurePriorities) {
9
+ this.measureParamCode = measureParamCode;
10
+ this.numericValue = numericValue;
11
+ this.measurePriorities = measurePriorities;
12
+ }
13
+ static make(measurement) {
14
+ // The measurement.code seems to be used in CET to connect the value to
15
+ // pre-existing fields in the product, such as width, height and depth.
16
+ // We however only use this for anchoring and stretching and so it is the
17
+ // code of the measureParam that is relevant. Hence Measurements with no
18
+ // measureParam are ignored.
19
+ var _a;
20
+ const measureParam = measurement.measureParam;
21
+ if (measureParam === undefined) {
22
+ return undefined;
23
+ }
24
+ const code = measureParam.code;
25
+ return new this(code, measurement.numericValue, ((_a = measureParam.measurePriority) !== null && _a !== void 0 ? _a : []).map((p, index) => ({
26
+ modelLocalFilePath: p.url,
27
+ index,
28
+ })));
29
+ }
30
+ }
@@ -1,269 +1,269 @@
1
- import { AggregatedLoadingObservable, LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParams, DtoConfProd, DtoMeasureParam, DtoMtrlApplication, DtoPrices, 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) => DtoConfProd;
140
- setDtoConf: (s: DtoConfProd, 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) => DtoConfProd;
260
- setDtoConf: (s: DtoConfProd, 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, DtoCatalogueParams, DtoConfProd, DtoMeasureParam, DtoMtrlApplication, DtoPrices, 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) => DtoConfProd;
140
+ setDtoConf: (s: DtoConfProd, 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) => DtoConfProd;
260
+ setDtoConf: (s: DtoConfProd, 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
+ }
269
269
  //# sourceMappingURL=CfgProduct.d.ts.map