@configura/web-api 1.6.1-alpha.4 → 1.6.1

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 (76) hide show
  1. package/.eslintrc.json +18 -0
  2. package/LICENSE +201 -201
  3. package/README.md +1 -1
  4. package/dist/CatalogueAPI.d.ts +507 -511
  5. package/dist/CatalogueAPI.js +280 -273
  6. package/dist/CfgMeasure.d.ts +32 -32
  7. package/dist/CfgMeasure.js +30 -30
  8. package/dist/CfgProduct.d.ts +258 -257
  9. package/dist/CfgProduct.js +747 -732
  10. package/dist/index.d.ts +20 -20
  11. package/dist/index.js +20 -20
  12. package/dist/material/CfgMaterialMapping.d.ts +7 -7
  13. package/dist/material/CfgMaterialMapping.js +181 -181
  14. package/dist/material/CfgMtrlApplication.d.ts +18 -18
  15. package/dist/material/CfgMtrlApplication.js +43 -43
  16. package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
  17. package/dist/material/CfgMtrlApplicationSource.js +8 -8
  18. package/dist/material/CfgMtrlSource.d.ts +19 -19
  19. package/dist/material/CfgMtrlSource.js +40 -40
  20. package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
  21. package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
  22. package/dist/productConfiguration/CfgFeature.d.ts +188 -179
  23. package/dist/productConfiguration/CfgFeature.js +636 -617
  24. package/dist/productConfiguration/CfgOption.d.ts +150 -150
  25. package/dist/productConfiguration/CfgOption.js +426 -426
  26. package/dist/productConfiguration/CfgProductConfiguration.d.ts +120 -120
  27. package/dist/productConfiguration/CfgProductConfiguration.js +309 -307
  28. package/dist/productConfiguration/filters.d.ts +15 -15
  29. package/dist/productConfiguration/filters.js +70 -70
  30. package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
  31. package/dist/productConfiguration/productParamsGenerator.js +51 -51
  32. package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
  33. package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -80
  34. package/dist/productLoader.d.ts +33 -33
  35. package/dist/productLoader.js +49 -49
  36. package/dist/syncGroups/SyncGroupsApplyMode.d.ts +20 -20
  37. package/dist/syncGroups/SyncGroupsApplyMode.js +21 -21
  38. package/dist/syncGroups/SyncGroupsHandler.d.ts +40 -39
  39. package/dist/syncGroups/SyncGroupsHandler.js +358 -352
  40. package/dist/syncGroups/SyncGroupsPathHelper.d.ts +26 -26
  41. package/dist/syncGroups/SyncGroupsPathHelper.js +90 -89
  42. package/dist/syncGroups/SyncGroupsState.d.ts +35 -25
  43. package/dist/syncGroups/SyncGroupsState.js +125 -111
  44. package/dist/syncGroups/SyncGroupsTransaction.d.ts +154 -50
  45. package/dist/syncGroups/SyncGroupsTransaction.js +576 -100
  46. package/dist/tasks/TaskHandler.d.ts +78 -78
  47. package/dist/tasks/TaskHandler.js +276 -265
  48. package/dist/tasks/formats.d.ts +4 -4
  49. package/dist/tasks/formats.js +7 -7
  50. package/dist/tests/testData/collectorForTest.d.ts +73 -73
  51. package/dist/tests/testData/collectorForTest.js +194 -195
  52. package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
  53. package/dist/tests/testData/dummyProductForTest.js +36 -36
  54. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -32
  55. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +277 -277
  56. package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
  57. package/dist/tests/testData/testDataCachedGetProduct.js +185 -185
  58. package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
  59. package/dist/tests/testData/testDataCachedPostValidate.js +183 -183
  60. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
  61. package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
  62. package/dist/tests/testData/testDataOptions.d.ts +12 -12
  63. package/dist/tests/testData/testDataOptions.js +60 -60
  64. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
  65. package/dist/tests/testData/testDataProductAggregatedPrice.js +187 -187
  66. package/dist/tests/testData/testDataUpcharge.d.ts +8 -29
  67. package/dist/tests/testData/testDataUpcharge.js +119 -119
  68. package/dist/utilitiesCatalogueData.d.ts +31 -31
  69. package/dist/utilitiesCatalogueData.js +162 -168
  70. package/dist/utilitiesCataloguePermission.d.ts +37 -39
  71. package/dist/utilitiesCataloguePermission.js +80 -84
  72. package/dist/utilitiesNumericValues.d.ts +24 -24
  73. package/dist/utilitiesNumericValues.js +109 -109
  74. package/package.json +3 -3
  75. package/dist/syncGroups/SyncGroupsApplier.d.ts +0 -20
  76. package/dist/syncGroups/SyncGroupsApplier.js +0 -520
@@ -1,49 +1,49 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { PromiseCache } from "@configura/web-utilities";
11
- import { makeProductKey, makeSelOptionsKey, } from "./utilitiesCatalogueData.js";
12
- /**
13
- * Wraps a getProduct function so that it caches for the time it lives.
14
- *
15
- * It has no cache invalidation or timeouts, so whatever ends up in the cache stays there
16
- * indefinitely. For this reason we recommend using this with caution.
17
- *
18
- * In our Example App we use it to cache the internal calls in additional products as in such a
19
- * product you tend to frequently get calls to same sub-product. Such as loading the same table leg
20
- * four times.
21
- */
22
- export function wrapWithGetProductCache(getProduct) {
23
- const cache = new PromiseCache();
24
- return (params) => __awaiter(this, void 0, void 0, function* () { return cache.get(makeProductKey(params, params.partNumber), () => getProduct(params)); });
25
- }
26
- /**
27
- * Wraps a postValidate function so that it caches for the time it lives.
28
- *
29
- * It has no cache invalidation or timeouts, so whatever ends up in the cache stays there
30
- * indefinitely. We recommend you do not use this unless you are really, really sure what you are
31
- * doing.
32
- *
33
- * The SDK uses it for additional products to avoid validating for example the same table legs four
34
- * times at the same time. There we make sure the this cache only stays in scope for one user
35
- * interaction. No longer than the actions caused by a user clicking an option.
36
- */
37
- export function wrapWithPostValidateCache(postValidate) {
38
- const cache = new PromiseCache();
39
- return (params, body) => __awaiter(this, void 0, void 0, function* () {
40
- return cache.get(`${makeProductKey(params, params.partNumber)}-${makeSelOptionsKey(body.selOptions)}`, () => postValidate(params, body));
41
- });
42
- }
43
- /** Does both wrapWithGetProductCache and wrapWithPostValidateCache. */
44
- export function wrapWithCache(loader) {
45
- return {
46
- getProduct: wrapWithGetProductCache(loader.getProduct.bind(loader)),
47
- postValidate: wrapWithPostValidateCache(loader.postValidate.bind(loader)),
48
- };
49
- }
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { PromiseCache } from "@configura/web-utilities";
11
+ import { makeProductKey, makeSelOptionsKey, } from "./utilitiesCatalogueData.js";
12
+ /**
13
+ * Wraps a getProduct function so that it caches for the time it lives.
14
+ *
15
+ * It has no cache invalidation or timeouts, so whatever ends up in the cache stays there
16
+ * indefinitely. For this reason we recommend using this with caution.
17
+ *
18
+ * In our Example App we use it to cache the internal calls in additional products as in such a
19
+ * product you tend to frequently get calls to same sub-product. Such as loading the same table leg
20
+ * four times.
21
+ */
22
+ export function wrapWithGetProductCache(getProduct) {
23
+ const cache = new PromiseCache();
24
+ return (params) => __awaiter(this, void 0, void 0, function* () { return cache.get(makeProductKey(params, params.partNumber), () => getProduct(params)); });
25
+ }
26
+ /**
27
+ * Wraps a postValidate function so that it caches for the time it lives.
28
+ *
29
+ * It has no cache invalidation or timeouts, so whatever ends up in the cache stays there
30
+ * indefinitely. We recommend you do not use this unless you are really, really sure what you are
31
+ * doing.
32
+ *
33
+ * The SDK uses it for additional products to avoid validating for example the same table legs four
34
+ * times at the same time. There we make sure the this cache only stays in scope for one user
35
+ * interaction. No longer than the actions caused by a user clicking an option.
36
+ */
37
+ export function wrapWithPostValidateCache(postValidate) {
38
+ const cache = new PromiseCache();
39
+ return (params, body) => __awaiter(this, void 0, void 0, function* () {
40
+ return cache.get(`${makeProductKey(params, params.partNumber)}-${makeSelOptionsKey(body.selOptions)}`, () => postValidate(params, body));
41
+ });
42
+ }
43
+ /** Does both wrapWithGetProductCache and wrapWithPostValidateCache. */
44
+ export function wrapWithCache(loader) {
45
+ return {
46
+ getProduct: wrapWithGetProductCache(loader.getProduct.bind(loader)),
47
+ postValidate: wrapWithPostValidateCache(loader.postValidate.bind(loader)),
48
+ };
49
+ }
@@ -1,21 +1,21 @@
1
- /**
2
- * The SyncGroupsApplyMode controls how many SyncGroups can be updated in the SyncState for one
3
- * run of rootProductOntoSyncState.
4
- *
5
- * "Fast" will update any SyncGroup that should be updated before running syncStateOntoRootProduct
6
- * This way several SyncGroups can be applied in one go before sending the validation calls to the * server, making the whole process faster.
7
- *
8
- * The downside of this is that is not exactly how CET (the desktop software) works. CET will
9
- * instead apply Features to the SyncState as soon as it gets the chance.
10
- *
11
- * "Strict" tries to behave exactly as CET. This will potentially generate a lot more validate
12
- * calls, increasing delay and cost.
13
- *
14
- * Strict is the safer option of the two, but we still recommend trying out Fast since it should
15
- * work fine in most cases.
16
- */
17
- export declare enum SyncGroupsApplyMode {
18
- Strict = "Strict",
19
- Fast = "Fast"
20
- }
1
+ /**
2
+ * The SyncGroupsApplyMode controls how many SyncGroups can be updated in the SyncState for one
3
+ * run of rootProductOntoSyncState.
4
+ *
5
+ * "Fast" will update any SyncGroup that should be updated before running syncStateOntoRootProduct
6
+ * This way several SyncGroups can be applied in one go before sending the validation calls to the * server, making the whole process faster.
7
+ *
8
+ * The downside of this is that is not exactly how CET (the desktop software) works. CET will
9
+ * instead apply Features to the SyncState as soon as it gets the chance.
10
+ *
11
+ * "Strict" tries to behave exactly as CET. This will potentially generate a lot more validate
12
+ * calls, increasing delay and cost.
13
+ *
14
+ * Strict is the safer option of the two, but we still recommend trying out Fast since it should
15
+ * work fine in most cases.
16
+ */
17
+ export declare enum SyncGroupsApplyMode {
18
+ Strict = "Strict",
19
+ Fast = "Fast"
20
+ }
21
21
  //# sourceMappingURL=SyncGroupsApplyMode.d.ts.map
@@ -1,21 +1,21 @@
1
- /**
2
- * The SyncGroupsApplyMode controls how many SyncGroups can be updated in the SyncState for one
3
- * run of rootProductOntoSyncState.
4
- *
5
- * "Fast" will update any SyncGroup that should be updated before running syncStateOntoRootProduct
6
- * This way several SyncGroups can be applied in one go before sending the validation calls to the * server, making the whole process faster.
7
- *
8
- * The downside of this is that is not exactly how CET (the desktop software) works. CET will
9
- * instead apply Features to the SyncState as soon as it gets the chance.
10
- *
11
- * "Strict" tries to behave exactly as CET. This will potentially generate a lot more validate
12
- * calls, increasing delay and cost.
13
- *
14
- * Strict is the safer option of the two, but we still recommend trying out Fast since it should
15
- * work fine in most cases.
16
- */
17
- export var SyncGroupsApplyMode;
18
- (function (SyncGroupsApplyMode) {
19
- SyncGroupsApplyMode["Strict"] = "Strict";
20
- SyncGroupsApplyMode["Fast"] = "Fast";
21
- })(SyncGroupsApplyMode || (SyncGroupsApplyMode = {}));
1
+ /**
2
+ * The SyncGroupsApplyMode controls how many SyncGroups can be updated in the SyncState for one
3
+ * run of rootProductOntoSyncState.
4
+ *
5
+ * "Fast" will update any SyncGroup that should be updated before running syncStateOntoRootProduct
6
+ * This way several SyncGroups can be applied in one go before sending the validation calls to the * server, making the whole process faster.
7
+ *
8
+ * The downside of this is that is not exactly how CET (the desktop software) works. CET will
9
+ * instead apply Features to the SyncState as soon as it gets the chance.
10
+ *
11
+ * "Strict" tries to behave exactly as CET. This will potentially generate a lot more validate
12
+ * calls, increasing delay and cost.
13
+ *
14
+ * Strict is the safer option of the two, but we still recommend trying out Fast since it should
15
+ * work fine in most cases.
16
+ */
17
+ export var SyncGroupsApplyMode;
18
+ (function (SyncGroupsApplyMode) {
19
+ SyncGroupsApplyMode["Strict"] = "Strict";
20
+ SyncGroupsApplyMode["Fast"] = "Fast";
21
+ })(SyncGroupsApplyMode || (SyncGroupsApplyMode = {}));
@@ -1,40 +1,41 @@
1
- import { AggregatedLoadingObservable } from "@configura/web-utilities";
2
- import { _CfgProductInternal } from "../CfgProduct.js";
3
- import { _CfgOptionInternal } from "../productConfiguration/CfgOption.js";
4
- import { ProductLoader } from "../productLoader.js";
5
- import { SyncGroupsApplyMode } from "./SyncGroupsApplyMode.js";
6
- import { SyncGroupsTransaction } from "./SyncGroupsTransaction.js";
7
- export declare type SyncCode = string;
8
- export declare type OptionCode = string;
9
- /**
10
- * Is used to apply the SyncGroups functionality on the Configuration and the other
11
- * way around. It also keeps the SyncState.
12
- */
13
- export declare class SyncGroupsHandler {
14
- private _syncState;
15
- readonly updateMode: SyncGroupsApplyMode;
16
- private readonly _loadingObservable;
17
- private _currentTransaction;
18
- static make(updateMode?: SyncGroupsApplyMode, loadingObservable?: AggregatedLoadingObservable): SyncGroupsHandler;
19
- private constructor();
20
- /**
21
- * Please note that clones will use the same loadingObservable as their source
22
- */
23
- clone(): SyncGroupsHandler;
24
- /**
25
- * Used to initially apply the sync state onto a new product so that it is "in sync"
26
- */
27
- init(product: _CfgProductInternal, productLoader: ProductLoader): Promise<void>;
28
- /**
29
- * Used when an Option is selected or deselected to apply all consequences of the sync groups.
30
- * Can cause multiple extra validation calls to the server.
31
- */
32
- selectOption(product: _CfgProductInternal, option: _CfgOptionInternal, on: boolean, productLoader: ProductLoader): Promise<boolean>;
33
- private _pending;
34
- private setPending;
35
- get pending(): _CfgOptionInternal | undefined;
36
- newTransaction(product: _CfgProductInternal, productLoader: ProductLoader, assumeNoStartProductState: boolean): Promise<SyncGroupsTransaction>;
37
- private closeTransaction;
38
- applyTransaction(transaction: SyncGroupsTransaction): Promise<void>;
39
- }
1
+ import { AggregatedLoadingObservable } from "@configura/web-utilities";
2
+ import { _CfgProductInternal } from "../CfgProduct.js";
3
+ import { _CfgOptionInternal } from "../productConfiguration/CfgOption.js";
4
+ import { ProductLoader } from "../productLoader.js";
5
+ import { SyncGroupsApplyMode } from "./SyncGroupsApplyMode.js";
6
+ import { SyncGroupsTransaction } from "./SyncGroupsTransaction.js";
7
+ export declare type SyncCode = string;
8
+ export declare type OptionCode = string;
9
+ /**
10
+ * Is used to apply the SyncGroups functionality on the Configuration and the other way around.
11
+ * It also keeps the SyncState.
12
+ */
13
+ export declare class SyncGroupsHandler {
14
+ private _syncState;
15
+ readonly updateMode: SyncGroupsApplyMode;
16
+ private readonly _loadingObservable;
17
+ private _currentTransaction;
18
+ /**
19
+ * @param verboseLogging Set to true to get verbose sync state changes logged to the console.
20
+ */
21
+ static make(updateMode?: SyncGroupsApplyMode, loadingObservable?: AggregatedLoadingObservable, verboseLogging?: boolean): SyncGroupsHandler;
22
+ private constructor();
23
+ /** Please note that clones will use the same loadingObservable as their source. */
24
+ clone(): SyncGroupsHandler;
25
+ get verboseLogging(): boolean;
26
+ set verboseLogging(v: boolean);
27
+ /** Used to initially apply the sync state onto a new product so that it is "in sync". */
28
+ init(product: _CfgProductInternal, productLoader: ProductLoader): Promise<void>;
29
+ /**
30
+ * Used when an Option is selected or deselected to apply all consequences of the sync groups.
31
+ * Can cause multiple extra validation calls to the server.
32
+ */
33
+ selectOption(product: _CfgProductInternal, option: _CfgOptionInternal, on: boolean, productLoader: ProductLoader): Promise<boolean>;
34
+ private _pending;
35
+ private setPending;
36
+ get pending(): _CfgOptionInternal | undefined;
37
+ private newTransaction;
38
+ private closeTransaction;
39
+ commitTransaction(transaction: SyncGroupsTransaction): Promise<void>;
40
+ }
40
41
  //# sourceMappingURL=SyncGroupsHandler.d.ts.map