@configura/web-api 1.4.0 → 1.6.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.
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +511 -504
- package/dist/CatalogueAPI.js +273 -248
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +263 -217
- package/dist/CfgProduct.js +763 -636
- package/dist/index.d.ts +20 -16
- package/dist/index.js +20 -16
- package/dist/material/CfgMaterialMapping.d.ts +7 -7
- package/dist/material/CfgMaterialMapping.js +181 -181
- package/dist/material/CfgMtrlApplication.d.ts +18 -18
- package/dist/material/CfgMtrlApplication.js +43 -43
- package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
- package/dist/material/CfgMtrlApplicationSource.js +8 -8
- package/dist/material/CfgMtrlSource.d.ts +19 -19
- package/dist/material/CfgMtrlSource.js +40 -40
- package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
- package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
- package/dist/productConfiguration/CfgFeature.d.ts +181 -160
- package/dist/productConfiguration/CfgFeature.js +648 -593
- package/dist/productConfiguration/CfgOption.d.ts +139 -128
- package/dist/productConfiguration/CfgOption.js +421 -394
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +122 -120
- package/dist/productConfiguration/CfgProductConfiguration.js +324 -307
- package/dist/productConfiguration/filters.d.ts +15 -15
- package/dist/productConfiguration/filters.js +67 -67
- package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
- package/dist/productConfiguration/productParamsGenerator.js +51 -51
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
- package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -80
- package/dist/productLoader.d.ts +33 -33
- package/dist/productLoader.js +49 -49
- package/dist/syncGroups/SyncGroupsApplier.d.ts +20 -0
- package/dist/syncGroups/SyncGroupsApplier.js +518 -0
- package/dist/syncGroups/SyncGroupsApplyMode.d.ts +15 -0
- package/dist/syncGroups/SyncGroupsApplyMode.js +15 -0
- package/dist/syncGroups/SyncGroupsHandler.d.ts +30 -0
- package/dist/syncGroups/SyncGroupsHandler.js +71 -0
- package/dist/syncGroups/SyncGroupsState.d.ts +20 -0
- package/dist/syncGroups/SyncGroupsState.js +61 -0
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +50 -0
- package/dist/syncGroups/SyncGroupsTransaction.js +106 -0
- package/dist/tasks/TaskHandler.d.ts +79 -0
- package/dist/tasks/TaskHandler.js +265 -0
- package/dist/tasks/formats.d.ts +5 -0
- package/dist/tasks/formats.js +7 -0
- package/dist/tests/testData/collectorForTest.d.ts +73 -73
- package/dist/tests/testData/collectorForTest.js +195 -195
- package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
- package/dist/tests/testData/dummyProductForTest.js +36 -36
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +32 -32
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +277 -348
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +185 -196
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +183 -183
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
- package/dist/tests/testData/testDataOptions.d.ts +13 -0
- package/dist/tests/testData/testDataOptions.js +60 -0
- package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
- package/dist/tests/testData/testDataProductAggregatedPrice.js +187 -198
- package/dist/tests/testData/testDataUpcharge.d.ts +29 -29
- package/dist/tests/testData/testDataUpcharge.js +119 -151
- package/dist/utilitiesCatalogueData.d.ts +25 -25
- package/dist/utilitiesCatalogueData.js +64 -64
- package/dist/utilitiesCataloguePermission.d.ts +39 -39
- package/dist/utilitiesCataloguePermission.js +84 -84
- package/dist/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +109 -109
- package/package.json +3 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CfgPath, _CfgProductInternal } from "../CfgProduct.js";
|
|
2
|
+
import { ProductLoader } from "../productLoader.js";
|
|
3
|
+
import { SyncGroupsApplyMode } from "./SyncGroupsApplyMode.js";
|
|
4
|
+
import { SyncGroupsTransaction } from "./SyncGroupsTransaction.js";
|
|
5
|
+
export declare type SyncCode = string;
|
|
6
|
+
export declare type OptionCode = string;
|
|
7
|
+
/**
|
|
8
|
+
* Is used to apply the SyncGroups functionality on the Configuration and the other
|
|
9
|
+
* way around. It also keeps the SyncState.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SyncGroupsHandler {
|
|
12
|
+
private _syncState;
|
|
13
|
+
readonly updateMode: SyncGroupsApplyMode;
|
|
14
|
+
private _currentTransaction;
|
|
15
|
+
static make(updateMode?: SyncGroupsApplyMode): SyncGroupsHandler;
|
|
16
|
+
private constructor();
|
|
17
|
+
clone(): SyncGroupsHandler;
|
|
18
|
+
/**
|
|
19
|
+
* Used to initially apply the sync state onto a new product so that it is "in sync"
|
|
20
|
+
*/
|
|
21
|
+
init(product: _CfgProductInternal, productLoader: ProductLoader): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Used when an Option is selected or deselected to apply all consequences of the sync groups.
|
|
24
|
+
* Can cause multiple extra validation calls to the server.
|
|
25
|
+
*/
|
|
26
|
+
selectOption(product: _CfgProductInternal, optionPath: CfgPath, on: boolean, productLoader: ProductLoader): Promise<boolean>;
|
|
27
|
+
newTransaction(product: _CfgProductInternal, productLoader: ProductLoader, assumeNoStartProductState: boolean): Promise<SyncGroupsTransaction>;
|
|
28
|
+
applyTransaction(transaction: SyncGroupsTransaction): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=SyncGroupsHandler.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
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 { SyncGroupsApplyMode } from "./SyncGroupsApplyMode.js";
|
|
11
|
+
import { SyncGroupsState } from "./SyncGroupsState.js";
|
|
12
|
+
import { SyncGroupsTransaction } from "./SyncGroupsTransaction.js";
|
|
13
|
+
/**
|
|
14
|
+
* Is used to apply the SyncGroups functionality on the Configuration and the other
|
|
15
|
+
* way around. It also keeps the SyncState.
|
|
16
|
+
*/
|
|
17
|
+
export class SyncGroupsHandler {
|
|
18
|
+
constructor(_syncState, updateMode) {
|
|
19
|
+
this._syncState = _syncState;
|
|
20
|
+
this.updateMode = updateMode;
|
|
21
|
+
}
|
|
22
|
+
static make(updateMode = SyncGroupsApplyMode.Fast) {
|
|
23
|
+
return new SyncGroupsHandler(new SyncGroupsState(), updateMode);
|
|
24
|
+
}
|
|
25
|
+
clone() {
|
|
26
|
+
return new SyncGroupsHandler(this._syncState.clone(), this.updateMode);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Used to initially apply the sync state onto a new product so that it is "in sync"
|
|
30
|
+
*/
|
|
31
|
+
init(product, productLoader) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const transaction = yield this.newTransaction(product, productLoader, true);
|
|
34
|
+
yield transaction.init();
|
|
35
|
+
yield this.applyTransaction(transaction);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Used when an Option is selected or deselected to apply all consequences of the sync groups.
|
|
40
|
+
* Can cause multiple extra validation calls to the server.
|
|
41
|
+
*/
|
|
42
|
+
selectOption(product, optionPath, on, productLoader) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
//todo: should we guarantee that it will use root? Tricky...
|
|
45
|
+
const transaction = yield this.newTransaction(product, productLoader, false);
|
|
46
|
+
const change = yield transaction.selectOption(optionPath, on);
|
|
47
|
+
// We always apply. The change-result above only tells if the configuration
|
|
48
|
+
// has changed. The SyncState may also have changed.
|
|
49
|
+
yield this.applyTransaction(transaction);
|
|
50
|
+
return change;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
newTransaction(product, productLoader, assumeNoStartProductState) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (this._currentTransaction !== undefined) {
|
|
56
|
+
this._currentTransaction.abort();
|
|
57
|
+
}
|
|
58
|
+
this._currentTransaction = yield SyncGroupsTransaction.make(this._syncState, this.updateMode, product, productLoader, assumeNoStartProductState);
|
|
59
|
+
return this._currentTransaction;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
applyTransaction(transaction) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
if (transaction.isAborted) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this._syncState.setFrom(transaction.syncState);
|
|
68
|
+
yield transaction.original.copyFrom(transaction.target, false, transaction.productLoader);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OptionCode, SyncCode } from "./SyncGroupsHandler.js";
|
|
2
|
+
/**
|
|
3
|
+
* Is used to keep track of the current value of the SyncGroups. Is fully separated between
|
|
4
|
+
* SelectOne and SelectMany as Features of the two types are synced separately.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SyncGroupsState {
|
|
7
|
+
readonly _selectOne: Map<SyncCode, OptionCode>;
|
|
8
|
+
readonly _selectMany: Map<SyncCode, Map<OptionCode, boolean>>;
|
|
9
|
+
clone(): SyncGroupsState;
|
|
10
|
+
/**
|
|
11
|
+
* Replaces the current state
|
|
12
|
+
*/
|
|
13
|
+
setFrom(other: SyncGroupsState): void;
|
|
14
|
+
setForSelectOne(syncCode: SyncCode, optionCode: OptionCode): void;
|
|
15
|
+
setForSelectMany(syncCode: SyncCode, optionCode: OptionCode, selected: boolean): void;
|
|
16
|
+
getForSelectOne(syncCode: SyncCode): OptionCode | undefined;
|
|
17
|
+
getForSelectMany(syncCode: SyncCode, optionCode: OptionCode): boolean | undefined;
|
|
18
|
+
logDebug(): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=SyncGroupsState.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Is used to keep track of the current value of the SyncGroups. Is fully separated between
|
|
3
|
+
* SelectOne and SelectMany as Features of the two types are synced separately.
|
|
4
|
+
*/
|
|
5
|
+
export class SyncGroupsState {
|
|
6
|
+
constructor() {
|
|
7
|
+
this._selectOne = new Map();
|
|
8
|
+
this._selectMany = new Map();
|
|
9
|
+
}
|
|
10
|
+
clone() {
|
|
11
|
+
const result = new SyncGroupsState();
|
|
12
|
+
result.setFrom(this);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Replaces the current state
|
|
17
|
+
*/
|
|
18
|
+
setFrom(other) {
|
|
19
|
+
this._selectOne.clear();
|
|
20
|
+
this._selectMany.clear();
|
|
21
|
+
for (const [k, v] of other._selectOne) {
|
|
22
|
+
this._selectOne.set(k, v);
|
|
23
|
+
}
|
|
24
|
+
for (const [sourceSyncCode, sourceOptionToSelected] of other._selectMany) {
|
|
25
|
+
const targetOptionToSelected = new Map();
|
|
26
|
+
for (const [sourceOptionCode, sourceIsSelected] of sourceOptionToSelected) {
|
|
27
|
+
targetOptionToSelected.set(sourceOptionCode, sourceIsSelected);
|
|
28
|
+
}
|
|
29
|
+
this._selectMany.set(sourceSyncCode, targetOptionToSelected);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
setForSelectOne(syncCode, optionCode) {
|
|
33
|
+
this._selectOne.set(syncCode, optionCode);
|
|
34
|
+
this.logDebug();
|
|
35
|
+
}
|
|
36
|
+
setForSelectMany(syncCode, optionCode, selected) {
|
|
37
|
+
let forSyncCode = this._selectMany.get(syncCode);
|
|
38
|
+
if (forSyncCode === undefined) {
|
|
39
|
+
forSyncCode = new Map();
|
|
40
|
+
this._selectMany.set(syncCode, forSyncCode);
|
|
41
|
+
}
|
|
42
|
+
forSyncCode.set(optionCode, selected);
|
|
43
|
+
this.logDebug();
|
|
44
|
+
}
|
|
45
|
+
getForSelectOne(syncCode) {
|
|
46
|
+
return this._selectOne.get(syncCode);
|
|
47
|
+
}
|
|
48
|
+
getForSelectMany(syncCode, optionCode) {
|
|
49
|
+
var _a;
|
|
50
|
+
return (_a = this._selectMany.get(syncCode)) === null || _a === void 0 ? void 0 : _a.get(optionCode);
|
|
51
|
+
}
|
|
52
|
+
logDebug() {
|
|
53
|
+
console.table(Array.from(this._selectOne.entries()));
|
|
54
|
+
console.table(Array.from(this._selectMany.entries()).reduce((a, [groupCode, optionCodeToSelected]) => {
|
|
55
|
+
for (const [optionCode, selected] of optionCodeToSelected) {
|
|
56
|
+
a.push([groupCode, optionCode, selected]);
|
|
57
|
+
}
|
|
58
|
+
return a;
|
|
59
|
+
}, []));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CfgPath, _CfgProductInternal } from "../CfgProduct.js";
|
|
2
|
+
import { _CfgFeatureInternal } from "../productConfiguration/CfgFeature.js";
|
|
3
|
+
import { _CfgOptionInternal } from "../productConfiguration/CfgOption.js";
|
|
4
|
+
import { ProductLoader } from "../productLoader.js";
|
|
5
|
+
import { SyncGroupsApplyMode } from "./SyncGroupsApplyMode.js";
|
|
6
|
+
import { OptionCode, SyncCode } from "./SyncGroupsHandler.js";
|
|
7
|
+
import { SyncGroupsState } from "./SyncGroupsState.js";
|
|
8
|
+
/**
|
|
9
|
+
* A transaction is normally limited to one user interaction. Like opening a product or
|
|
10
|
+
* selecting an option. This object is used to keep data for one transaction. In particular
|
|
11
|
+
* what Features and what SyncGroups have been affected in the transaction. This is a means
|
|
12
|
+
* to eliminate the risk of infinite loops.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SyncGroupsTransaction {
|
|
15
|
+
readonly syncState: SyncGroupsState;
|
|
16
|
+
readonly updateMode: SyncGroupsApplyMode;
|
|
17
|
+
readonly productLoader: ProductLoader;
|
|
18
|
+
readonly original: _CfgProductInternal;
|
|
19
|
+
readonly target: _CfgProductInternal;
|
|
20
|
+
readonly initial: _CfgProductInternal | undefined;
|
|
21
|
+
static make(syncState: SyncGroupsState, updateMode: SyncGroupsApplyMode, product: _CfgProductInternal, productLoader: ProductLoader, assumeNoStartState: boolean): Promise<SyncGroupsTransaction>;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param syncState A clone of the original syncState. Replaces the original syncState if nothing fails and the transaction doesn't get aborted
|
|
25
|
+
* @param updateMode
|
|
26
|
+
* @param productLoader
|
|
27
|
+
* @param original The product instance that this transaction will be applied on provided nothing fails and the transaction doesn't get aborted
|
|
28
|
+
* @param target A clone of the original product used to apply the configuration changes to
|
|
29
|
+
* @param initial A clone of the original product used to track what the original state was. As a safe measure we do not use originalProduct for this, as it might be changed by someone else
|
|
30
|
+
*/
|
|
31
|
+
private constructor();
|
|
32
|
+
private _aborted;
|
|
33
|
+
private affectedSelectOneFeatures;
|
|
34
|
+
private affectedSelectManyOptions;
|
|
35
|
+
private affectedSelectOneSyncGroups;
|
|
36
|
+
private affectedSelectManySyncGroupsAndOptions;
|
|
37
|
+
get isAborted(): boolean;
|
|
38
|
+
abort(): void;
|
|
39
|
+
init(): Promise<boolean>;
|
|
40
|
+
selectOption(optionPath: CfgPath, on: boolean): Promise<boolean>;
|
|
41
|
+
addSelectOneFeatureAffected(feature: _CfgFeatureInternal): void;
|
|
42
|
+
addSelectManyOptionAffected(option: _CfgOptionInternal): void;
|
|
43
|
+
hasSelectOneFeatureBeenAffected(feature: _CfgFeatureInternal): boolean;
|
|
44
|
+
hasSelectManyOptionBeenAffected(option: _CfgOptionInternal): boolean;
|
|
45
|
+
addSyncGroupAffectedForSelectOne(syncCode: SyncCode): void;
|
|
46
|
+
addSyncGroupAffectedForSelectMany(syncCode: SyncCode, optionCode: OptionCode): void;
|
|
47
|
+
isSyncGroupAffectedForSelectOne(syncCode: SyncCode): boolean;
|
|
48
|
+
isSyncGroupAffectedForSelectMany(syncCode: SyncCode, optionCode: OptionCode): boolean;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=SyncGroupsTransaction.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
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 { SelectionType } from "../productConfiguration/CfgFeature.js";
|
|
11
|
+
import { SyncGroupsApplier } from "./SyncGroupsApplier.js";
|
|
12
|
+
/**
|
|
13
|
+
* A transaction is normally limited to one user interaction. Like opening a product or
|
|
14
|
+
* selecting an option. This object is used to keep data for one transaction. In particular
|
|
15
|
+
* what Features and what SyncGroups have been affected in the transaction. This is a means
|
|
16
|
+
* to eliminate the risk of infinite loops.
|
|
17
|
+
*/
|
|
18
|
+
export class SyncGroupsTransaction {
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param syncState A clone of the original syncState. Replaces the original syncState if nothing fails and the transaction doesn't get aborted
|
|
22
|
+
* @param updateMode
|
|
23
|
+
* @param productLoader
|
|
24
|
+
* @param original The product instance that this transaction will be applied on provided nothing fails and the transaction doesn't get aborted
|
|
25
|
+
* @param target A clone of the original product used to apply the configuration changes to
|
|
26
|
+
* @param initial A clone of the original product used to track what the original state was. As a safe measure we do not use originalProduct for this, as it might be changed by someone else
|
|
27
|
+
*/
|
|
28
|
+
constructor(syncState, updateMode, productLoader, original, target, initial) {
|
|
29
|
+
this.syncState = syncState;
|
|
30
|
+
this.updateMode = updateMode;
|
|
31
|
+
this.productLoader = productLoader;
|
|
32
|
+
this.original = original;
|
|
33
|
+
this.target = target;
|
|
34
|
+
this.initial = initial;
|
|
35
|
+
this._aborted = false;
|
|
36
|
+
this.affectedSelectOneFeatures = new Set();
|
|
37
|
+
this.affectedSelectManyOptions = new Set();
|
|
38
|
+
this.affectedSelectOneSyncGroups = new Set();
|
|
39
|
+
this.affectedSelectManySyncGroupsAndOptions = new Map();
|
|
40
|
+
}
|
|
41
|
+
static make(syncState, updateMode, product, productLoader, assumeNoStartState) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const t = new this(syncState.clone(), updateMode, productLoader, product, yield product.clone(), assumeNoStartState ? undefined : yield product.clone());
|
|
44
|
+
return t;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
get isAborted() {
|
|
48
|
+
return this._aborted;
|
|
49
|
+
}
|
|
50
|
+
abort() {
|
|
51
|
+
this._aborted = true;
|
|
52
|
+
}
|
|
53
|
+
init() {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return yield SyncGroupsApplier.init(this);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
selectOption(optionPath, on) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const targetOption = this.target.getOptionFromPath(optionPath);
|
|
61
|
+
return yield SyncGroupsApplier.selectOption(this, targetOption, on);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
addSelectOneFeatureAffected(feature) {
|
|
65
|
+
if (feature.selectionType !== SelectionType.SelectOne) {
|
|
66
|
+
throw new Error("Can only be used for SelectOne Feature");
|
|
67
|
+
}
|
|
68
|
+
this.affectedSelectOneFeatures.add(feature);
|
|
69
|
+
}
|
|
70
|
+
addSelectManyOptionAffected(option) {
|
|
71
|
+
if (option.parent.selectionType !== SelectionType.SelectMany) {
|
|
72
|
+
throw new Error("Can only be used for option in SelectMany Feature");
|
|
73
|
+
}
|
|
74
|
+
this.affectedSelectManyOptions.add(option);
|
|
75
|
+
}
|
|
76
|
+
hasSelectOneFeatureBeenAffected(feature) {
|
|
77
|
+
if (feature.selectionType !== SelectionType.SelectOne) {
|
|
78
|
+
throw new Error("Can only be used for SelectOne Feature");
|
|
79
|
+
}
|
|
80
|
+
return this.affectedSelectOneFeatures.has(feature);
|
|
81
|
+
}
|
|
82
|
+
hasSelectManyOptionBeenAffected(option) {
|
|
83
|
+
if (option.parent.selectionType !== SelectionType.SelectMany) {
|
|
84
|
+
throw new Error("Can only be used for option in SelectMany Feature");
|
|
85
|
+
}
|
|
86
|
+
return this.affectedSelectManyOptions.has(option);
|
|
87
|
+
}
|
|
88
|
+
addSyncGroupAffectedForSelectOne(syncCode) {
|
|
89
|
+
this.affectedSelectOneSyncGroups.add(syncCode);
|
|
90
|
+
}
|
|
91
|
+
addSyncGroupAffectedForSelectMany(syncCode, optionCode) {
|
|
92
|
+
let forSyncCode = this.affectedSelectManySyncGroupsAndOptions.get(syncCode);
|
|
93
|
+
if (forSyncCode === undefined) {
|
|
94
|
+
forSyncCode = new Set();
|
|
95
|
+
this.affectedSelectManySyncGroupsAndOptions.set(syncCode, forSyncCode);
|
|
96
|
+
}
|
|
97
|
+
forSyncCode.add(optionCode);
|
|
98
|
+
}
|
|
99
|
+
isSyncGroupAffectedForSelectOne(syncCode) {
|
|
100
|
+
return this.affectedSelectOneSyncGroups.has(syncCode);
|
|
101
|
+
}
|
|
102
|
+
isSyncGroupAffectedForSelectMany(syncCode, optionCode) {
|
|
103
|
+
var _a;
|
|
104
|
+
return ((_a = this.affectedSelectManySyncGroupsAndOptions.get(syncCode)) === null || _a === void 0 ? void 0 : _a.has(optionCode)) === true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Observable, SingleArgCallback } from "@configura/web-utilities";
|
|
2
|
+
import { AdditionalProductConfiguration, CatalogueAPI, ExportStatus, ExportStatusStatus, PostExportParams, PostRenderParams, RenderStatus, RenderStatusStatus, TargetCameraArgs } from "../CatalogueAPI.js";
|
|
3
|
+
import { CfgProduct } from "../CfgProduct.js";
|
|
4
|
+
import { RenderOrExportFormat } from "./formats.js";
|
|
5
|
+
export declare type TasksChangeNotification = {
|
|
6
|
+
freshRef: TaskHandler;
|
|
7
|
+
};
|
|
8
|
+
export declare type RenderTaskParams = {
|
|
9
|
+
targetCameraArgs?: TargetCameraArgs;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
export declare type ProductParams = PostRenderParams | PostExportParams;
|
|
14
|
+
export declare class _TaskHandlerInternal {
|
|
15
|
+
api: CatalogueAPI;
|
|
16
|
+
readonly changeObservable: Observable<TasksChangeNotification>;
|
|
17
|
+
readonly tasks: Task<RenderOrExportFormat>[];
|
|
18
|
+
constructor(api: CatalogueAPI);
|
|
19
|
+
_notifyAllOfChange: () => Promise<void>;
|
|
20
|
+
destroy: () => void;
|
|
21
|
+
get hasExport(): boolean;
|
|
22
|
+
get hasRender(): boolean;
|
|
23
|
+
get availableFormats(): RenderOrExportFormat[];
|
|
24
|
+
start: (format: RenderOrExportFormat, product: CfgProduct, renderParams: RenderTaskParams | undefined, getPreviewUrl: (() => Promise<string>) | undefined) => Promise<void>;
|
|
25
|
+
addTask(task: Task<RenderOrExportFormat>): void;
|
|
26
|
+
removeTask(task: Task<RenderOrExportFormat>): void;
|
|
27
|
+
}
|
|
28
|
+
export declare class TaskHandler {
|
|
29
|
+
private readonly _internal;
|
|
30
|
+
static make(api: CatalogueAPI): TaskHandler;
|
|
31
|
+
/**
|
|
32
|
+
* Makes an object wrapping the passed object. This is not a clone method,
|
|
33
|
+
* it is a method to make a new outer reference. Like a shallow copy.
|
|
34
|
+
* We use this to help frameworks that are build around using equals to detect change.
|
|
35
|
+
*/
|
|
36
|
+
static _makeNewRefFrom(internal: _TaskHandlerInternal): TaskHandler;
|
|
37
|
+
private constructor();
|
|
38
|
+
destroy: () => void;
|
|
39
|
+
get tasks(): Task<RenderOrExportFormat>[];
|
|
40
|
+
get hasExport(): boolean;
|
|
41
|
+
get hasRender(): boolean;
|
|
42
|
+
get availableFormats(): RenderOrExportFormat[];
|
|
43
|
+
start: (format: RenderOrExportFormat, product: CfgProduct, renderParams?: RenderTaskParams | undefined, getPreviewUrl?: (() => Promise<string>) | undefined) => Promise<void>;
|
|
44
|
+
listenForChange: (l: SingleArgCallback<TasksChangeNotification>) => void;
|
|
45
|
+
stopListenForChange: (l: SingleArgCallback<TasksChangeNotification>) => void;
|
|
46
|
+
}
|
|
47
|
+
declare type TaskStatus = RenderStatusStatus | ExportStatusStatus | "abandoned";
|
|
48
|
+
export declare abstract class Task<F extends RenderOrExportFormat> {
|
|
49
|
+
protected readonly taskHandler: _TaskHandlerInternal;
|
|
50
|
+
readonly format: F;
|
|
51
|
+
private _timerId;
|
|
52
|
+
protected constructor(taskHandler: _TaskHandlerInternal, format: F, product: CfgProduct, getPreviewUrl: (() => Promise<string>) | undefined);
|
|
53
|
+
protected abstract postInit(): Promise<RenderStatus | ExportStatus>;
|
|
54
|
+
protected abstract pollStatus(): Promise<RenderStatus | ExportStatus>;
|
|
55
|
+
protected _productParams: ProductParams;
|
|
56
|
+
protected _apiSelection: AdditionalProductConfiguration;
|
|
57
|
+
private _status;
|
|
58
|
+
private _uuid;
|
|
59
|
+
private _created;
|
|
60
|
+
private _modified;
|
|
61
|
+
private _url;
|
|
62
|
+
private _previewUrl;
|
|
63
|
+
private setStatus;
|
|
64
|
+
get status(): TaskStatus;
|
|
65
|
+
get uuid(): string;
|
|
66
|
+
get created(): string;
|
|
67
|
+
get modified(): string;
|
|
68
|
+
get url(): string | undefined;
|
|
69
|
+
get previewUrl(): string | undefined;
|
|
70
|
+
private _start;
|
|
71
|
+
protected startAndRegister: () => Promise<void>;
|
|
72
|
+
restart: () => Promise<void>;
|
|
73
|
+
private scheduleRefresh;
|
|
74
|
+
private refresh;
|
|
75
|
+
private stop;
|
|
76
|
+
abort: () => void;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=TaskHandler.d.ts.map
|