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

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 (53) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +1 -1
  3. package/dist/CatalogueAPI.d.ts +448 -448
  4. package/dist/CatalogueAPI.js +206 -206
  5. package/dist/CfgProduct.d.ts +116 -116
  6. package/dist/CfgProduct.js +588 -588
  7. package/dist/index.d.ts +15 -15
  8. package/dist/index.js +15 -15
  9. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  10. package/dist/material/CfgMaterialMapping.js +176 -176
  11. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  12. package/dist/material/CfgMtrlApplication.js +43 -43
  13. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  14. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  15. package/dist/material/CfgMtrlSource.d.ts +19 -19
  16. package/dist/material/CfgMtrlSource.js +40 -40
  17. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  18. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  19. package/dist/productConfiguration/CfgFeature.d.ts +134 -80
  20. package/dist/productConfiguration/CfgFeature.js +483 -451
  21. package/dist/productConfiguration/CfgOption.d.ts +112 -64
  22. package/dist/productConfiguration/CfgOption.js +293 -263
  23. package/dist/productConfiguration/CfgProductConfiguration.d.ts +50 -50
  24. package/dist/productConfiguration/CfgProductConfiguration.js +198 -198
  25. package/dist/productConfiguration/filters.d.ts +7 -7
  26. package/dist/productConfiguration/filters.js +29 -29
  27. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  28. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  29. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +9 -9
  30. package/dist/productConfiguration/utilitiesProductConfiguration.js +61 -61
  31. package/dist/productLoader.d.ts +11 -11
  32. package/dist/productLoader.js +41 -41
  33. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  34. package/dist/tests/testData/collectorForTest.js +195 -195
  35. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  36. package/dist/tests/testData/dummyProductForTest.js +35 -35
  37. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +32 -32
  38. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +368 -368
  39. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  40. package/dist/tests/testData/testDataCachedGetProduct.js +199 -199
  41. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  42. package/dist/tests/testData/testDataCachedPostValidate.js +189 -189
  43. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  44. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1117 -1117
  45. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +28 -28
  46. package/dist/tests/testData/testDataProductAggregatedPrice.js +205 -205
  47. package/dist/tests/testData/testDataUpcharge.d.ts +29 -29
  48. package/dist/tests/testData/testDataUpcharge.js +159 -159
  49. package/dist/utilitiesCatalogueData.d.ts +20 -18
  50. package/dist/utilitiesCatalogueData.js +64 -56
  51. package/dist/utilitiesCataloguePermission.d.ts +39 -39
  52. package/dist/utilitiesCataloguePermission.js +84 -84
  53. package/package.json +3 -3
@@ -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,81 +1,135 @@
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
- Group = 0,
9
- SelectOne = 1,
10
- SelectMany = 2
11
- }
12
- export declare type FeatureChangeNotification = {
13
- freshRef: CfgFeature;
14
- };
15
- export declare class _CfgFeatureInternal {
16
- readonly rawFeature: Feature;
17
- private readonly allRawFeatures;
18
- readonly key: string;
19
- readonly parent: _CfgProductConfigurationInternal | _CfgOptionInternal;
20
- readonly parentProduct: _CfgProductInternal;
21
- readonly rootProduct: _CfgProductInternal;
22
- constructor(rawFeature: Feature, allRawFeatures: Feature[], key: string, // Unique amongst siblings
23
- parent: _CfgProductConfigurationInternal | _CfgOptionInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal);
24
- readonly selectionType: SelectionType;
25
- private _options;
26
- private readonly _selectedOptions;
27
- private _mtrlApplications;
28
- readonly hasUpcharge: boolean;
29
- readonly changeObservable: Observable<FeatureChangeNotification>;
30
- get code(): string;
31
- get groupCode(): string | undefined;
32
- get description(): string;
33
- get mtrlApplications(): CfgMtrlApplication[];
34
- get selectedOptions(): CfgOption[];
35
- private get isAllOptionsAffectedByAnySelection();
36
- get preview(): string | undefined;
37
- get visibleIfAdditionalProduct(): boolean;
38
- get visibleIfMainProduct(): boolean;
39
- get visible(): boolean;
40
- get options(): CfgOption[];
41
- private _notifyAllOfChange;
42
- _childHasChanged: (childOption: _CfgOptionInternal, bubbleMode: ProductConfigurationBubbleMode) => Promise<void>;
43
- getApiSelection: () => {
44
- [index: string]: SelectedOption;
45
- } | undefined;
46
- setApiSelection: (apiOptionSelectionMap: {
47
- [index: string]: SelectedOption;
48
- } | undefined) => Promise<boolean>;
49
- structureCompare: (other: _CfgFeatureInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
50
- tryMatchSelection: (other: _CfgFeatureInternal, descriptionMatch?: boolean) => Promise<boolean>;
51
- selectOption: (optionInternal: _CfgOptionInternal, on: boolean, bubbleMode: ProductConfigurationBubbleMode) => Promise<boolean>;
52
- isSelected: (option: _CfgOptionInternal) => boolean;
53
- keyMatch: (other: _CfgFeatureInternal, descriptionMatch?: boolean) => boolean;
54
- _getFeaturesWithCode: (code: string) => _CfgFeatureInternal[];
55
- private _freshRefAllOptions;
56
- _freshRefDescendants(): void;
57
- }
58
- export declare class CfgFeature {
59
- readonly _internal: _CfgFeatureInternal;
60
- static make: (rawFeature: Feature, allRawFeatures: Feature[], key: string, parent: _CfgProductConfigurationInternal | _CfgOptionInternal, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal) => CfgFeature;
61
- static _makeNewRefFrom: (internal: _CfgFeatureInternal) => CfgFeature;
62
- private constructor();
63
- isBackedBySame: (other: CfgFeature) => boolean;
64
- get parentProduct(): CfgProduct;
65
- get rootProduct(): CfgProduct;
66
- get selectionType(): SelectionType;
67
- get key(): string;
68
- get code(): string;
69
- get groupCode(): string | undefined;
70
- get description(): string;
71
- get hasUpcharge(): boolean | undefined;
72
- get selectedOptions(): CfgOption[];
73
- get preview(): string | undefined;
74
- get options(): CfgOption[];
75
- get visible(): boolean;
76
- selectOption: (option: CfgOption, on: boolean) => Promise<boolean>;
77
- isSelected: (option: CfgOption) => boolean;
78
- listenForChange: (l: SingleArgCallback<FeatureChangeNotification>) => void;
79
- stopListenForChange: (l: SingleArgCallback<FeatureChangeNotification>) => void;
80
- }
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
+ }
81
135
  //# sourceMappingURL=CfgFeature.d.ts.map