@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,20 +1,20 @@
1
- export declare abstract class CfgMtrlSource {
2
- abstract isSame(other: CfgMtrlSource): boolean;
3
- }
4
- export declare class CfgMtrlSourceUrl extends CfgMtrlSource {
5
- private _url;
6
- private _urlIsFromProperty;
7
- constructor(_url: string, _urlIsFromProperty: string);
8
- get url(): string;
9
- get urlIsFromProperty(): string;
10
- isSame(other: CfgMtrlSource): boolean;
11
- }
12
- export declare class CfgMtrlSourceBuffer extends CfgMtrlSource {
13
- private _fileName;
14
- private _buffer;
15
- constructor(_fileName: string, _buffer: ArrayBuffer);
16
- get fileName(): string;
17
- get buffer(): ArrayBuffer;
18
- isSame(other: CfgMtrlSource): boolean;
19
- }
1
+ export declare abstract class CfgMtrlSource {
2
+ abstract isSame(other: CfgMtrlSource): boolean;
3
+ }
4
+ export declare class CfgMtrlSourceUrl extends CfgMtrlSource {
5
+ private _url;
6
+ private _urlIsFromProperty;
7
+ constructor(_url: string, _urlIsFromProperty: string);
8
+ get url(): string;
9
+ get urlIsFromProperty(): string;
10
+ isSame(other: CfgMtrlSource): boolean;
11
+ }
12
+ export declare class CfgMtrlSourceBuffer extends CfgMtrlSource {
13
+ private _fileName;
14
+ private _buffer;
15
+ constructor(_fileName: string, _buffer: ArrayBuffer);
16
+ get fileName(): string;
17
+ get buffer(): ArrayBuffer;
18
+ isSame(other: CfgMtrlSource): boolean;
19
+ }
20
20
  //# sourceMappingURL=CfgMtrlSource.d.ts.map
@@ -1,40 +1,40 @@
1
- export class CfgMtrlSource {
2
- }
3
- export class CfgMtrlSourceUrl extends CfgMtrlSource {
4
- constructor(_url, _urlIsFromProperty) {
5
- super();
6
- this._url = _url;
7
- this._urlIsFromProperty = _urlIsFromProperty;
8
- }
9
- get url() {
10
- return this._url;
11
- }
12
- get urlIsFromProperty() {
13
- return this._urlIsFromProperty;
14
- }
15
- isSame(other) {
16
- if (!(other instanceof CfgMtrlSourceUrl)) {
17
- return false;
18
- }
19
- return this.url === other.url;
20
- }
21
- }
22
- export class CfgMtrlSourceBuffer extends CfgMtrlSource {
23
- constructor(_fileName, _buffer) {
24
- super();
25
- this._fileName = _fileName;
26
- this._buffer = _buffer;
27
- }
28
- get fileName() {
29
- return this._fileName;
30
- }
31
- get buffer() {
32
- return this._buffer;
33
- }
34
- isSame(other) {
35
- if (!(other instanceof CfgMtrlSourceBuffer)) {
36
- return false;
37
- }
38
- return this.fileName === other.fileName;
39
- }
40
- }
1
+ export class CfgMtrlSource {
2
+ }
3
+ export class CfgMtrlSourceUrl extends CfgMtrlSource {
4
+ constructor(_url, _urlIsFromProperty) {
5
+ super();
6
+ this._url = _url;
7
+ this._urlIsFromProperty = _urlIsFromProperty;
8
+ }
9
+ get url() {
10
+ return this._url;
11
+ }
12
+ get urlIsFromProperty() {
13
+ return this._urlIsFromProperty;
14
+ }
15
+ isSame(other) {
16
+ if (!(other instanceof CfgMtrlSourceUrl)) {
17
+ return false;
18
+ }
19
+ return this.url === other.url;
20
+ }
21
+ }
22
+ export class CfgMtrlSourceBuffer extends CfgMtrlSource {
23
+ constructor(_fileName, _buffer) {
24
+ super();
25
+ this._fileName = _fileName;
26
+ this._buffer = _buffer;
27
+ }
28
+ get fileName() {
29
+ return this._fileName;
30
+ }
31
+ get buffer() {
32
+ return this._buffer;
33
+ }
34
+ isSame(other) {
35
+ if (!(other instanceof CfgMtrlSourceBuffer)) {
36
+ return false;
37
+ }
38
+ return this.fileName === other.fileName;
39
+ }
40
+ }
@@ -1,8 +1,8 @@
1
- import { CfgMtrlApplication } from "./CfgMtrlApplication.js";
2
- import { CfgMtrlSource } from "./CfgMtrlSource.js";
3
- export interface CfgMtrlSourceWithMetaData {
4
- mtrl: CfgMtrlSource;
5
- source: CfgMtrlApplication;
6
- overriddenByOption: boolean;
7
- }
1
+ import { CfgMtrlApplication } from "./CfgMtrlApplication.js";
2
+ import { CfgMtrlSource } from "./CfgMtrlSource.js";
3
+ export interface CfgMtrlSourceWithMetaData {
4
+ mtrl: CfgMtrlSource;
5
+ source: CfgMtrlApplication;
6
+ overriddenByOption: boolean;
7
+ }
8
8
  //# sourceMappingURL=CfgMtrlSourceWithMetaData.d.ts.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,135 +1,161 @@
1
- import { Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { Feature, SelectedOption } from "../CatalogueAPI.js";
3
- import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
4
- import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
5
- import { CfgOption, ProductConfigurationBubbleMode, _CfgOptionInternal } from "./CfgOption.js";
6
- import { _CfgProductConfigurationInternal } from "./CfgProductConfiguration.js";
7
- export declare enum SelectionType {
8
- /**
9
- * All options are permanently selected. In our ui-component for this we skip over this level,
10
- * and immediately show the children, but you could do this differently, like for instance
11
- * showing the group heading.
12
- */
13
- Group = 0,
14
- /**
15
- * One and only one can be selected at a time. This normally corresponds to either a dropdown
16
- * menu or radio buttons.
17
- */
18
- SelectOne = 1,
19
- /** Zero to all can be selected at a time. This normally corresponds to checkboxes. */
20
- SelectMany = 2
21
- }
22
- export declare type FeatureChangeNotification = {
23
- freshRef: CfgFeature;
24
- };
25
- /**
26
- * This class is meant to only be used through CfgFeature. It should
27
- * never be instantiated on its own. Normally the internal state of this class
28
- * should never be directly modified. CfgFeature is the class that
29
- * should be used and interacted with.
30
- */
31
- export declare class _CfgFeatureInternal {
32
- readonly rawFeature: Feature;
33
- private readonly allRawFeatures;
34
- readonly key: string;
35
- readonly parent: _CfgProductConfigurationInternal | _CfgOptionInternal;
36
- readonly parentProduct: _CfgProductInternal;
37
- readonly rootProduct: _CfgProductInternal;
38
- constructor(rawFeature: Feature, allRawFeatures: Feature[], key: string, // Unique amongst siblings
39
- parent: _CfgProductConfigurationInternal | _CfgOptionInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal);
40
- readonly selectionType: SelectionType;
41
- private _options;
42
- private readonly _selectedOptions;
43
- private _mtrlApplications;
44
- readonly hasUpcharge: boolean;
45
- readonly changeObservable: Observable<FeatureChangeNotification>;
46
- get code(): string;
47
- get groupCode(): string | undefined;
48
- get description(): string;
49
- get mtrlApplications(): CfgMtrlApplication[];
50
- get selectedOptions(): CfgOption[];
51
- get ancestorsSelected(): boolean;
52
- /**
53
- * If one option is selected or deselected this will potentially
54
- * affect all other Options on this Feature
55
- */
56
- private get isAllOptionsAffectedByAnySelection();
57
- get preview(): string | undefined;
58
- get visibleIfAdditionalProduct(): boolean;
59
- get visibleIfMainProduct(): boolean;
60
- get visible(): boolean;
61
- get options(): CfgOption[];
62
- private _notifyAllOfChange;
63
- /**
64
- * Called by child to tell its parent that it has changed.
65
- * @throws Will throw if options have not yet been generated. This should be impossible
66
- * as nonexisting children can not call their parent.
67
- */
68
- _childHasChanged: (childOption: _CfgOptionInternal, bubbleMode: ProductConfigurationBubbleMode) => Promise<void>;
69
- getApiSelection: () => {
70
- [index: string]: SelectedOption;
71
- } | undefined;
72
- setApiSelection: (apiOptionSelectionMap: {
73
- [index: string]: SelectedOption;
74
- } | undefined) => Promise<boolean>;
75
- structureCompare: (other: _CfgFeatureInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
76
- tryMatchSelection: (other: _CfgFeatureInternal, descriptionMatch?: boolean) => Promise<boolean>;
77
- /**
78
- * Normally this is used through methods on CfgFeature and CfgOption. Use this
79
- * internal version if you need to control the bubbleMode.
80
- * Using a validate bubbleMode will cause validation calls to the server.
81
- */
82
- selectOption: (optionInternal: _CfgOptionInternal, on: boolean, bubbleMode: ProductConfigurationBubbleMode) => Promise<boolean>;
83
- isSelected: (option: _CfgOptionInternal) => boolean;
84
- keyMatch: (other: _CfgFeatureInternal, descriptionMatch?: boolean) => boolean;
85
- /** Only in selected options */
86
- _getFeaturesWithCode: (code: string) => _CfgFeatureInternal[];
87
- /**
88
- * Make fresh references to all options on this feature.
89
- * Also includes currently selected options.
90
- * @throws Will throw if options have not yet been generated.
91
- */
92
- private _freshRefAllOptions;
93
- _freshRefDescendants(): void;
94
- }
95
- export declare class CfgFeature {
96
- readonly _internal: _CfgFeatureInternal;
97
- static make: (rawFeature: Feature, allRawFeatures: Feature[], key: string, parent: _CfgProductConfigurationInternal | _CfgOptionInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal) => CfgFeature;
98
- /**
99
- * Makes an object wrapping the passed object. This is not a clone method,
100
- * it is a method to make a new outer reference. Like a shallow copy.
101
- * We use this to help frameworks that are built around using equals to detect change.
102
- */
103
- static _makeNewRefFrom: (internal: _CfgFeatureInternal) => CfgFeature;
104
- /**
105
- * Private constructor and make-method because make new ref requires the constructor to
106
- * take an internal and we don't want those who instantiate CfgFeature to have to be aware
107
- * of the internal.
108
- */
109
- private constructor();
110
- isBackedBySame: (other: CfgFeature) => boolean;
111
- get parentProduct(): CfgProduct;
112
- get rootProduct(): CfgProduct;
113
- get selectionType(): SelectionType;
114
- get key(): string;
115
- get code(): string;
116
- get groupCode(): string | undefined;
117
- get description(): string;
118
- get hasUpcharge(): boolean | undefined;
119
- get selectedOptions(): CfgOption[];
120
- /** Are all ancestors up to the CfgProductConfiguration selected? */
121
- get ancestorsSelected(): boolean;
122
- get preview(): string | undefined;
123
- get options(): CfgOption[];
124
- get visible(): boolean;
125
- /**
126
- * Selects the passed Option.
127
- * Only Options belonging to Features that are "select many" can be deselected.
128
- * Calling this will cause a validation call to the server.
129
- */
130
- selectOption: (option: CfgOption, on: boolean) => Promise<boolean>;
131
- isSelected: (option: CfgOption) => boolean;
132
- listenForChange: (l: SingleArgCallback<FeatureChangeNotification>) => void;
133
- stopListenForChange: (l: SingleArgCallback<FeatureChangeNotification>) => void;
134
- }
1
+ import { LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
+ import { Feature, SelectedOption } from "../CatalogueAPI.js";
3
+ import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
4
+ import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
5
+ import { CfgOption, ProductConfigurationBubbleMode, _CfgOptionInternal } from "./CfgOption.js";
6
+ import { _CfgProductConfigurationInternal } from "./CfgProductConfiguration.js";
7
+ export declare enum SelectionType {
8
+ /**
9
+ * All options are permanently selected. In our ui-component for this we skip over this level,
10
+ * and immediately show the children, but you could do this differently, like for instance
11
+ * showing the group heading.
12
+ */
13
+ Group = 0,
14
+ /**
15
+ * One and only one can be selected at a time. This normally corresponds to either a dropdown
16
+ * menu or radio buttons.
17
+ */
18
+ SelectOne = 1,
19
+ /** Zero to all can be selected at a time. This normally corresponds to checkboxes. */
20
+ SelectMany = 2
21
+ }
22
+ export declare type FeatureChangeNotification = {
23
+ freshRef: CfgFeature;
24
+ };
25
+ /**
26
+ * This class is meant to only be used through CfgFeature. It should
27
+ * never be instantiated on its own. Normally the internal state of this class
28
+ * should never be directly modified. CfgFeature is the class that
29
+ * should be used and interacted with.
30
+ */
31
+ export declare class _CfgFeatureInternal {
32
+ readonly rawFeature: Feature;
33
+ private readonly allRawFeatures;
34
+ readonly key: string;
35
+ readonly parent: _CfgProductConfigurationInternal | _CfgOptionInternal;
36
+ readonly parentConfiguration: _CfgProductConfigurationInternal;
37
+ readonly parentProduct: _CfgProductInternal;
38
+ readonly rootProduct: _CfgProductInternal;
39
+ constructor(rawFeature: Feature, allRawFeatures: Feature[], key: string, // Unique amongst siblings
40
+ parent: _CfgProductConfigurationInternal | _CfgOptionInternal, parentConfiguration: _CfgProductConfigurationInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal);
41
+ readonly selectionType: SelectionType;
42
+ private _options;
43
+ private readonly _selectedOptions;
44
+ private _mtrlApplications;
45
+ readonly hasUpcharge: boolean;
46
+ readonly changeObservable: Observable<FeatureChangeNotification>;
47
+ get code(): string;
48
+ get groupCode(): string | undefined;
49
+ get isUseNumericValue(): boolean;
50
+ get numericValue(): number | undefined;
51
+ setNumericValue: (val: number) => Promise<boolean>;
52
+ get description(): string;
53
+ /**
54
+ * The MeasureParam class is re-used for different purposes. In Features it is used
55
+ * to indicate which stretch measures inside Models shall be affected by this state
56
+ * of this Feature. Hence only the code property is used.
57
+ */
58
+ get measureParamCodes(): string[] | undefined;
59
+ get unit(): LengthUnit;
60
+ get mtrlApplications(): CfgMtrlApplication[];
61
+ get selectedOptions(): CfgOption[];
62
+ get ancestorsSelected(): boolean;
63
+ /**
64
+ * If one option is selected or deselected this will potentially
65
+ * affect all other Options on this Feature
66
+ */
67
+ private get isAllOptionsAffectedByAnySelection();
68
+ get preview(): string | undefined;
69
+ get visibleIfAdditionalProduct(): boolean;
70
+ get visibleIfMainProduct(): boolean;
71
+ get visible(): boolean;
72
+ get options(): CfgOption[];
73
+ private _notifyAllOfChange;
74
+ /**
75
+ * Called by child to tell its parent that it has changed.
76
+ * @throws Will throw if options have not yet been generated. This should be impossible
77
+ * as nonexisting children can not call their parent.
78
+ */
79
+ _childHasChanged: (childOption: _CfgOptionInternal, bubbleMode: ProductConfigurationBubbleMode) => Promise<void>;
80
+ getApiSelection: () => {
81
+ [index: string]: SelectedOption;
82
+ } | undefined;
83
+ setApiSelection: (apiOptionSelectionMap: {
84
+ [index: string]: SelectedOption;
85
+ } | undefined) => Promise<boolean>;
86
+ /** Pushes to refresh stretch. Does not cause validation. */
87
+ pushStretch: () => Promise<boolean>;
88
+ structureCompare: (other: _CfgFeatureInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
89
+ tryMatchSelection: (other: _CfgFeatureInternal, descriptionMatch?: boolean) => Promise<boolean>;
90
+ /**
91
+ * Normally this is used through methods on CfgFeature and CfgOption. Use this
92
+ * internal version if you need to control the bubbleMode.
93
+ * Using a validate bubbleMode will cause validation calls to the server.
94
+ */
95
+ selectOption: (optionInternal: _CfgOptionInternal, on: boolean, bubbleMode: ProductConfigurationBubbleMode) => Promise<boolean>;
96
+ isSelected: (option: _CfgOptionInternal) => boolean;
97
+ keyMatch: (other: _CfgFeatureInternal, descriptionMatch?: boolean) => boolean;
98
+ /** Only in selected options */
99
+ _getFeaturesWithCode: (code: string) => _CfgFeatureInternal[];
100
+ /**
101
+ * Make fresh references to all options on this feature.
102
+ * Also includes currently selected options.
103
+ * @throws Will throw if options have not yet been generated.
104
+ */
105
+ private _freshRefAllOptions;
106
+ _freshRefDescendants(): void;
107
+ }
108
+ export declare class CfgFeature {
109
+ readonly _internal: _CfgFeatureInternal;
110
+ static make(rawFeature: Feature, allRawFeatures: Feature[], key: string, parent: _CfgProductConfigurationInternal | _CfgOptionInternal, parentConfiguration: _CfgProductConfigurationInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal): CfgFeature;
111
+ /**
112
+ * Makes an object wrapping the passed object. This is not a clone method,
113
+ * it is a method to make a new outer reference. Like a shallow copy.
114
+ * We use this to help frameworks that are built around using equals to detect change.
115
+ */
116
+ static _makeNewRefFrom(internal: _CfgFeatureInternal): CfgFeature;
117
+ /**
118
+ * Private constructor and make-method because make new ref requires the constructor to
119
+ * take an internal and we don't want those who instantiate CfgFeature to have to be aware
120
+ * of the internal.
121
+ */
122
+ private constructor();
123
+ isBackedBySame: (other: CfgFeature) => boolean;
124
+ get parentProduct(): CfgProduct;
125
+ get rootProduct(): CfgProduct;
126
+ get selectionType(): SelectionType;
127
+ get key(): string;
128
+ get code(): string;
129
+ get groupCode(): string | undefined;
130
+ /**
131
+ * If true the options in the feature is selected by both sending its code and numeric value
132
+ * when selecting.
133
+ */
134
+ get isUseNumericValue(): boolean;
135
+ /** This will read the numeric value of the selected option. */
136
+ get numericValue(): number | undefined;
137
+ /**
138
+ * This will find the first option allowing the value, set the value on it and select it.
139
+ * This is an implicit option-select.
140
+ */
141
+ setNumericValue: (val: number) => Promise<boolean>;
142
+ get unit(): LengthUnit;
143
+ get description(): string;
144
+ get hasUpcharge(): boolean | undefined;
145
+ get selectedOptions(): CfgOption[];
146
+ /** Are all ancestors up to the CfgProductConfiguration selected? */
147
+ get ancestorsSelected(): boolean;
148
+ get preview(): string | undefined;
149
+ get options(): CfgOption[];
150
+ get visible(): boolean;
151
+ /**
152
+ * Selects the passed Option.
153
+ * Only Options belonging to Features that are "select many" can be deselected.
154
+ * Calling this will cause a validation call to the server.
155
+ */
156
+ selectOption: (option: CfgOption, on: boolean) => Promise<boolean>;
157
+ isSelected: (option: CfgOption) => boolean;
158
+ listenForChange: (l: SingleArgCallback<FeatureChangeNotification>) => void;
159
+ stopListenForChange: (l: SingleArgCallback<FeatureChangeNotification>) => void;
160
+ }
135
161
  //# sourceMappingURL=CfgFeature.d.ts.map