@configura/web-api 1.3.0-alpha.4 → 1.4.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +1 -1
  3. package/dist/CatalogueAPI.d.ts +502 -448
  4. package/dist/CatalogueAPI.js +206 -206
  5. package/dist/CfgMeasure.d.ts +33 -0
  6. package/dist/CfgMeasure.js +30 -0
  7. package/dist/CfgProduct.d.ts +217 -116
  8. package/dist/CfgProduct.js +634 -588
  9. package/dist/index.d.ts +16 -15
  10. package/dist/index.js +16 -15
  11. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  12. package/dist/material/CfgMaterialMapping.js +181 -176
  13. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  14. package/dist/material/CfgMtrlApplication.js +43 -43
  15. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  16. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  17. package/dist/material/CfgMtrlSource.d.ts +19 -19
  18. package/dist/material/CfgMtrlSource.js +40 -40
  19. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  20. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  21. package/dist/productConfiguration/CfgFeature.d.ts +160 -134
  22. package/dist/productConfiguration/CfgFeature.js +593 -483
  23. package/dist/productConfiguration/CfgOption.d.ts +128 -112
  24. package/dist/productConfiguration/CfgOption.js +394 -293
  25. package/dist/productConfiguration/CfgProductConfiguration.d.ts +120 -50
  26. package/dist/productConfiguration/CfgProductConfiguration.js +307 -198
  27. package/dist/productConfiguration/filters.d.ts +7 -7
  28. package/dist/productConfiguration/filters.js +29 -29
  29. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  30. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  31. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -9
  32. package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -61
  33. package/dist/productLoader.d.ts +33 -11
  34. package/dist/productLoader.js +49 -41
  35. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  36. package/dist/tests/testData/collectorForTest.js +195 -195
  37. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  38. package/dist/tests/testData/dummyProductForTest.js +36 -35
  39. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +32 -32
  40. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +381 -368
  41. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  42. package/dist/tests/testData/testDataCachedGetProduct.js +205 -199
  43. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  44. package/dist/tests/testData/testDataCachedPostValidate.js +195 -189
  45. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  46. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1119 -1117
  47. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +28 -28
  48. package/dist/tests/testData/testDataProductAggregatedPrice.js +210 -205
  49. package/dist/tests/testData/testDataUpcharge.d.ts +29 -29
  50. package/dist/tests/testData/testDataUpcharge.js +163 -159
  51. package/dist/utilitiesCatalogueData.d.ts +22 -20
  52. package/dist/utilitiesCatalogueData.js +64 -64
  53. package/dist/utilitiesCataloguePermission.d.ts +39 -39
  54. package/dist/utilitiesCataloguePermission.js +84 -84
  55. package/dist/utilitiesNumericValues.d.ts +25 -0
  56. package/dist/utilitiesNumericValues.js +109 -0
  57. package/package.json +3 -3
@@ -1,113 +1,129 @@
1
- import { Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { Feature, Option, SelectedOption } from "../CatalogueAPI.js";
3
- import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
4
- import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
5
- import { CfgFeature, _CfgFeatureInternal } from "./CfgFeature.js";
6
- export declare type OptionChangeNotification = {
7
- freshRef: CfgOption;
8
- };
9
- export declare enum ProductConfigurationBubbleMode {
10
- /**
11
- * Bubble to the closest CfgProduct, let it revalidate, then that will continue
12
- * the bubble after validate. Turns on all ancestors all the way up.
13
- */
14
- Validate = "Validate",
15
- /**
16
- * Bubble to the closest CfgProduct, let it revalidate, then that will continue
17
- * the bubble after validate. If this is select it will turns on all ancestors all the way up.
18
- * So with this mode it is possible to select an option where its parents are not selected.
19
- */
20
- ValidateAndBubbleSelected = "ValidateAndBubbleSelected",
21
- /**
22
- * Stop bubbling
23
- * This mode supports internal functionality and is not expected to be used by integrators.
24
- */
25
- Stop = "Stop",
26
- /**
27
- * Bubble to the next level up the tree. In features-options the next level is considered
28
- * the next feature, so option levels are skipped over. The node we call from notifies its
29
- * parent, and the parent switches out the reference to the node. Then bubbling stops.
30
- * This mode supports internal functionality and is not expected to be used by integrators.
31
- */
32
- OneLevel = "OneLevel",
33
- /**
34
- * Bubble to the closest CfgProduct without doing any validation
35
- * This mode supports internal functionality and is not expected to be used by integrators.
36
- */
37
- ToParentProduct = "ToParentProduct",
38
- /**
39
- * Bubble to the root CfgProduct
40
- * This mode supports internal functionality and is not expected to be used by integrators.
41
- */
42
- ToRoot = "ToRoot"
43
- }
44
- /**
45
- * This class is meant to only be used through CfgOption. It should
46
- * never be instantiated on its own. Normally the internal state of this class
47
- * should never be directly modified. CfgOption is the class that
48
- * should be used and interacted with.
49
- */
50
- export declare class _CfgOptionInternal {
51
- readonly rawOption: Option;
52
- readonly parent: _CfgFeatureInternal;
53
- private readonly allRawFeatures;
54
- readonly parentProduct: _CfgProductInternal;
55
- readonly rootProduct: _CfgProductInternal;
56
- constructor(rawOption: Option, parent: _CfgFeatureInternal, allRawFeatures: Feature[], siblingHasDuplicateDescription: boolean, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal);
57
- private _features;
58
- private _mtrlApplications;
59
- readonly key: string;
60
- readonly changeObservable: Observable<OptionChangeNotification>;
61
- get code(): string;
62
- get description(): string;
63
- get selected(): boolean;
64
- get ancestorsSelected(): boolean;
65
- get mtrlApplications(): CfgMtrlApplication[];
66
- get thumbnail(): string | undefined;
67
- get upcharge(): number | undefined;
68
- get priceChangeAtSelectChange(): number | undefined;
69
- get features(): CfgFeature[];
70
- /** Called by child to tell its parent that it has changed. */
71
- _childHasChanged: (freshRef: CfgFeature, bubbleMode: ProductConfigurationBubbleMode) => Promise<void>;
72
- getApiSelection: () => SelectedOption;
73
- setApiSelection: (apiOptionSelection: SelectedOption | undefined) => Promise<boolean>;
74
- structureCompare: (other: _CfgOptionInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
75
- tryMatchSelection: (other: CfgOption, descriptionMatch?: boolean) => Promise<boolean>;
76
- keyMatch: (other: _CfgOptionInternal, descriptionMatch?: boolean) => boolean;
77
- _getFeaturesWithCode: (code: string) => _CfgFeatureInternal[];
78
- _freshRefDescendants(): void;
79
- }
80
- export declare class CfgOption {
81
- readonly _internal: _CfgOptionInternal;
82
- static make: (rawOption: Option, parent: _CfgFeatureInternal, allRawFeatures: Feature[], siblingHasDuplicateDescription: boolean, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal) => CfgOption;
83
- /**
84
- * Makes an object wrapping the passed object. This is not a clone method,
85
- * it is a method to make a new outer reference. Like a shallow copy.
86
- * We use this to help frameworks that are build around using equals to detect change.
87
- */
88
- static _makeNewRefFrom: (internal: _CfgOptionInternal) => CfgOption;
89
- /**
90
- * Private constructor and make-method because make new ref requires the constructor to
91
- * take an internal and we don't want those who instantiate CfgOption to have to be aware
92
- * of the internal.
93
- */
94
- private constructor();
95
- isBackedBySame: (other: CfgOption) => boolean;
96
- get parentProduct(): CfgProduct;
97
- get rootProduct(): CfgProduct;
98
- get rawOption(): Option;
99
- get key(): string;
100
- get code(): string;
101
- get description(): string;
102
- get selected(): boolean;
103
- /** Are all ancestors up to the CfgProductConfiguration selected? Includes self. */
104
- get ancestorsSelected(): boolean;
105
- setSelected: (on: boolean) => Promise<boolean>;
106
- get thumbnail(): string | undefined;
107
- get upcharge(): number | undefined;
108
- get priceChangeAtSelectChange(): number | undefined;
109
- get features(): CfgFeature[];
110
- listenForChange: (l: SingleArgCallback<OptionChangeNotification>) => void;
111
- stopListenForChange: (l: SingleArgCallback<OptionChangeNotification>) => void;
112
- }
1
+ import { LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
+ import { Feature, Option, SelectedOption } from "../CatalogueAPI.js";
3
+ import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
4
+ import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
5
+ import { NumericValuesSelection } from "../utilitiesNumericValues.js";
6
+ import { CfgFeature, _CfgFeatureInternal } from "./CfgFeature.js";
7
+ import { _CfgProductConfigurationInternal } from "./CfgProductConfiguration.js";
8
+ export declare type OptionChangeNotification = {
9
+ freshRef: CfgOption;
10
+ };
11
+ export declare enum ProductConfigurationBubbleMode {
12
+ /**
13
+ * Bubble to the closest CfgProduct, let it revalidate, then that will continue
14
+ * the bubble after validate. Turns on all ancestors all the way up.
15
+ */
16
+ Validate = "Validate",
17
+ /**
18
+ * Bubble to the closest CfgProduct, let it revalidate, then that will continue
19
+ * the bubble after validate. If this is select it will turns on all ancestors all the way up.
20
+ * So with this mode it is possible to select an option where its parents are not selected.
21
+ */
22
+ ValidateAndBubbleSelected = "ValidateAndBubbleSelected",
23
+ /**
24
+ * Stop bubbling
25
+ * This mode supports internal functionality and is not expected to be used by integrators.
26
+ */
27
+ Stop = "Stop",
28
+ /**
29
+ * Bubble to the next level up the tree. In features-options the next level is considered
30
+ * the next feature, so option levels are skipped over. The node we call from notifies its
31
+ * parent, and the parent switches out the reference to the node. Then bubbling stops.
32
+ * This mode supports internal functionality and is not expected to be used by integrators.
33
+ */
34
+ OneLevel = "OneLevel",
35
+ /**
36
+ * Bubble to the closest CfgProduct without doing any validation
37
+ * This mode supports internal functionality and is not expected to be used by integrators.
38
+ */
39
+ ToParentProduct = "ToParentProduct",
40
+ /**
41
+ * Bubble to the root CfgProduct
42
+ * This mode supports internal functionality and is not expected to be used by integrators.
43
+ */
44
+ ToRoot = "ToRoot"
45
+ }
46
+ /**
47
+ * This class is meant to only be used through CfgOption. It should
48
+ * never be instantiated on its own. Normally the internal state of this class
49
+ * should never be directly modified. CfgOption is the class that
50
+ * should be used and interacted with.
51
+ */
52
+ export declare class _CfgOptionInternal {
53
+ readonly rawOption: Option;
54
+ private readonly allRawFeatures;
55
+ readonly parent: _CfgFeatureInternal;
56
+ readonly parentConfiguration: _CfgProductConfigurationInternal;
57
+ readonly parentProduct: _CfgProductInternal;
58
+ readonly rootProduct: _CfgProductInternal;
59
+ constructor(rawOption: Option, allRawFeatures: Feature[], siblingHasDuplicateDescription: boolean, parent: _CfgFeatureInternal, parentConfiguration: _CfgProductConfigurationInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal);
60
+ private _features;
61
+ private _mtrlApplications;
62
+ readonly key: string;
63
+ private _numericValue;
64
+ readonly allowedNumericValues: NumericValuesSelection | undefined;
65
+ isAllowedNumericValue(val: number): boolean;
66
+ readonly changeObservable: Observable<OptionChangeNotification>;
67
+ get code(): string;
68
+ get isUseNumericValue(): boolean;
69
+ get numericValue(): number | undefined;
70
+ setNumericValue(val: number, doSelectOption: boolean): Promise<boolean>;
71
+ get unit(): LengthUnit;
72
+ get description(): string;
73
+ get selected(): boolean;
74
+ get ancestorsSelected(): boolean;
75
+ get mtrlApplications(): CfgMtrlApplication[];
76
+ get thumbnail(): string | undefined;
77
+ get upcharge(): number | undefined;
78
+ get priceChangeAtSelectChange(): number | undefined;
79
+ get features(): CfgFeature[];
80
+ /** Called by child to tell its parent that it has changed. */
81
+ _childHasChanged: (freshRef: CfgFeature, bubbleMode: ProductConfigurationBubbleMode) => Promise<void>;
82
+ getApiSelection: () => SelectedOption;
83
+ setApiSelection: (apiOptionSelection: SelectedOption | undefined) => Promise<boolean>;
84
+ structureCompare: (other: _CfgOptionInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
85
+ tryMatchSelection: (other: CfgOption, descriptionMatch?: boolean) => Promise<boolean>;
86
+ keyMatch: (other: _CfgOptionInternal, descriptionMatch?: boolean) => boolean;
87
+ _getFeaturesWithCode: (code: string) => _CfgFeatureInternal[];
88
+ _freshRefDescendants(): void;
89
+ }
90
+ export declare class CfgOption {
91
+ readonly _internal: _CfgOptionInternal;
92
+ static make(rawOption: Option, allRawFeatures: Feature[], siblingHasDuplicateDescription: boolean, parent: _CfgFeatureInternal, parentConfiguration: _CfgProductConfigurationInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal): CfgOption;
93
+ /**
94
+ * Makes an object wrapping the passed object. This is not a clone method,
95
+ * it is a method to make a new outer reference. Like a shallow copy.
96
+ * We use this to help frameworks that are build around using equals to detect change.
97
+ */
98
+ static _makeNewRefFrom(internal: _CfgOptionInternal): CfgOption;
99
+ /**
100
+ * Private constructor and make-method because make new ref requires the constructor to
101
+ * take an internal and we don't want those who instantiate CfgOption to have to be aware
102
+ * of the internal.
103
+ */
104
+ private constructor();
105
+ isBackedBySame: (other: CfgOption) => boolean;
106
+ get parentProduct(): CfgProduct;
107
+ get rootProduct(): CfgProduct;
108
+ get rawOption(): Option;
109
+ get key(): string;
110
+ get code(): string;
111
+ get isUseNumericValue(): boolean;
112
+ get numericValue(): number | undefined;
113
+ setNumericValue: (val: number, doSelectOption: boolean) => Promise<boolean>;
114
+ get allowedNumericValues(): NumericValuesSelection | undefined;
115
+ isAllowedNumericValue: (val: number) => boolean;
116
+ get unit(): LengthUnit;
117
+ get description(): string;
118
+ get selected(): boolean;
119
+ /** Are all ancestors up to the CfgProductConfiguration selected? Includes self. */
120
+ get ancestorsSelected(): boolean;
121
+ setSelected: (on: boolean) => Promise<boolean>;
122
+ get thumbnail(): string | undefined;
123
+ get upcharge(): number | undefined;
124
+ get priceChangeAtSelectChange(): number | undefined;
125
+ get features(): CfgFeature[];
126
+ listenForChange: (l: SingleArgCallback<OptionChangeNotification>) => void;
127
+ stopListenForChange: (l: SingleArgCallback<OptionChangeNotification>) => void;
128
+ }
113
129
  //# sourceMappingURL=CfgOption.d.ts.map