@configura/web-api 1.4.0-alpha.4 → 1.5.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 +239 -217
- package/dist/CfgProduct.js +668 -636
- package/dist/index.d.ts +18 -16
- package/dist/index.js +18 -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 +178 -160
- package/dist/productConfiguration/CfgFeature.js +611 -593
- package/dist/productConfiguration/CfgOption.d.ts +128 -128
- package/dist/productConfiguration/CfgOption.js +394 -394
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +120 -120
- package/dist/productConfiguration/CfgProductConfiguration.js +307 -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/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 +348 -348
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +196 -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/testDataProductAggregatedPrice.d.ts +6 -6
- package/dist/tests/testData/testDataProductAggregatedPrice.js +198 -198
- package/dist/tests/testData/testDataUpcharge.d.ts +29 -29
- package/dist/tests/testData/testDataUpcharge.js +151 -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
package/dist/productLoader.js
CHANGED
|
@@ -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
|
+
}
|
|
@@ -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
|
|
@@ -0,0 +1,265 @@
|
|
|
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 { Observable } from "@configura/web-utilities";
|
|
11
|
+
import { exportFormatNames, renderFormatNames, } from "../CatalogueAPI.js";
|
|
12
|
+
import { isExportFormat, isRenderFormat } from "./formats.js";
|
|
13
|
+
const productToParams = (product) => (Object.assign(Object.assign({ lang: product.lang }, product.catId), { partNumber: product.partNumber }));
|
|
14
|
+
export class _TaskHandlerInternal {
|
|
15
|
+
constructor(api) {
|
|
16
|
+
this.api = api;
|
|
17
|
+
this.changeObservable = new Observable();
|
|
18
|
+
this.tasks = [];
|
|
19
|
+
this._notifyAllOfChange = () => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const freshRef = TaskHandler._makeNewRefFrom(this);
|
|
21
|
+
this.changeObservable.notifyAll({ freshRef });
|
|
22
|
+
});
|
|
23
|
+
this.destroy = () => {
|
|
24
|
+
this.changeObservable.stopAllListen();
|
|
25
|
+
for (const task of this.tasks) {
|
|
26
|
+
task.abort();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
this.start = (format, product, renderParams, getPreviewUrl) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
if (isRenderFormat(format)) {
|
|
31
|
+
if (!this.hasRender) {
|
|
32
|
+
throw new Error("Render has not been activated for this Catalogue");
|
|
33
|
+
}
|
|
34
|
+
if (renderParams === undefined) {
|
|
35
|
+
throw new Error("renderParams must be set for render");
|
|
36
|
+
}
|
|
37
|
+
yield TaskRender.make(this, format, product, renderParams, getPreviewUrl);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (isExportFormat(format)) {
|
|
41
|
+
if (!this.hasExport) {
|
|
42
|
+
throw new Error("Export has not been activated for this Catalogue");
|
|
43
|
+
}
|
|
44
|
+
yield TaskExport.make(this, format, product, getPreviewUrl);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
throw new Error("Unknown export format");
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
get hasExport() {
|
|
51
|
+
return this.api.hasFeature("export");
|
|
52
|
+
}
|
|
53
|
+
get hasRender() {
|
|
54
|
+
return this.api.hasFeature("render");
|
|
55
|
+
}
|
|
56
|
+
get availableFormats() {
|
|
57
|
+
const result = [];
|
|
58
|
+
if (this.hasExport) {
|
|
59
|
+
result.push(...exportFormatNames);
|
|
60
|
+
}
|
|
61
|
+
if (this.hasRender) {
|
|
62
|
+
result.push(...renderFormatNames);
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
addTask(task) {
|
|
67
|
+
this.tasks.push(task);
|
|
68
|
+
this._notifyAllOfChange();
|
|
69
|
+
}
|
|
70
|
+
removeTask(task) {
|
|
71
|
+
const i = this.tasks.indexOf(task);
|
|
72
|
+
this.tasks.splice(i, 1);
|
|
73
|
+
this._notifyAllOfChange();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export class TaskHandler {
|
|
77
|
+
constructor(_internal) {
|
|
78
|
+
this._internal = _internal;
|
|
79
|
+
this.destroy = () => this._internal.destroy();
|
|
80
|
+
this.start = (format, product, renderParams, getPreviewUrl) => __awaiter(this, void 0, void 0, function* () { return this._internal.start(format, product, renderParams, getPreviewUrl); });
|
|
81
|
+
this.listenForChange = (l) => this._internal.changeObservable.listen(l);
|
|
82
|
+
this.stopListenForChange = (l) => this._internal.changeObservable.stopListen(l);
|
|
83
|
+
}
|
|
84
|
+
static make(api) {
|
|
85
|
+
return new this(new _TaskHandlerInternal(api));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Makes an object wrapping the passed object. This is not a clone method,
|
|
89
|
+
* it is a method to make a new outer reference. Like a shallow copy.
|
|
90
|
+
* We use this to help frameworks that are build around using equals to detect change.
|
|
91
|
+
*/
|
|
92
|
+
static _makeNewRefFrom(internal) {
|
|
93
|
+
return new this(internal);
|
|
94
|
+
}
|
|
95
|
+
get tasks() {
|
|
96
|
+
return this._internal.tasks;
|
|
97
|
+
}
|
|
98
|
+
get hasExport() {
|
|
99
|
+
return this._internal.hasExport;
|
|
100
|
+
}
|
|
101
|
+
get hasRender() {
|
|
102
|
+
return this._internal.hasRender;
|
|
103
|
+
}
|
|
104
|
+
get availableFormats() {
|
|
105
|
+
return this._internal.availableFormats;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export class Task {
|
|
109
|
+
constructor(taskHandler, format, product, getPreviewUrl) {
|
|
110
|
+
this.taskHandler = taskHandler;
|
|
111
|
+
this.format = format;
|
|
112
|
+
this._status = "pending";
|
|
113
|
+
this._start = () => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const result = yield this.postInit();
|
|
115
|
+
this._uuid = result.uuid;
|
|
116
|
+
this._created = result.created;
|
|
117
|
+
this._modified = result.modified;
|
|
118
|
+
this.setStatus(result.status);
|
|
119
|
+
this.scheduleRefresh();
|
|
120
|
+
});
|
|
121
|
+
this.startAndRegister = () => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
try {
|
|
123
|
+
yield this._start();
|
|
124
|
+
this.taskHandler.addTask(this);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
this.setStatus("failed");
|
|
128
|
+
console.error(e);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
this.restart = () => __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
try {
|
|
133
|
+
this.stop();
|
|
134
|
+
this.setStatus("pending");
|
|
135
|
+
yield this._start();
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
this.setStatus("failed");
|
|
139
|
+
console.error(e);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
this.scheduleRefresh = () => {
|
|
143
|
+
this._timerId = setTimeout(this.refresh, 1000);
|
|
144
|
+
};
|
|
145
|
+
this.refresh = () => __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
try {
|
|
147
|
+
const result = yield this.pollStatus();
|
|
148
|
+
this._modified = result.modified;
|
|
149
|
+
const status = result.status;
|
|
150
|
+
switch (status) {
|
|
151
|
+
case "finished":
|
|
152
|
+
const url = result.url;
|
|
153
|
+
if (!url) {
|
|
154
|
+
throw new Error("No URL from finished task");
|
|
155
|
+
}
|
|
156
|
+
this._url = url;
|
|
157
|
+
break;
|
|
158
|
+
case "failed":
|
|
159
|
+
break;
|
|
160
|
+
case "running":
|
|
161
|
+
case "pending":
|
|
162
|
+
this.scheduleRefresh();
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
this.setStatus(status);
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
this.setStatus("failed");
|
|
169
|
+
console.error(e);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
this.abort = () => {
|
|
173
|
+
this._status = "abandoned";
|
|
174
|
+
this.stop();
|
|
175
|
+
this.taskHandler.removeTask(this);
|
|
176
|
+
};
|
|
177
|
+
this._productParams = productToParams(product);
|
|
178
|
+
this._apiSelection = product.getApiSelection();
|
|
179
|
+
if (getPreviewUrl !== undefined) {
|
|
180
|
+
getPreviewUrl().then((dataUrl) => {
|
|
181
|
+
this._previewUrl = dataUrl;
|
|
182
|
+
this.taskHandler._notifyAllOfChange();
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
setStatus(status) {
|
|
187
|
+
const isChange = this._status !== status;
|
|
188
|
+
this._status = status;
|
|
189
|
+
if (isChange) {
|
|
190
|
+
this.taskHandler._notifyAllOfChange();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
get status() {
|
|
194
|
+
return this._status;
|
|
195
|
+
}
|
|
196
|
+
get uuid() {
|
|
197
|
+
if (this._uuid === undefined) {
|
|
198
|
+
throw new Error("Should not happen");
|
|
199
|
+
}
|
|
200
|
+
return this._uuid;
|
|
201
|
+
}
|
|
202
|
+
get created() {
|
|
203
|
+
if (this._created === undefined) {
|
|
204
|
+
throw new Error("Should not happen");
|
|
205
|
+
}
|
|
206
|
+
return this._created;
|
|
207
|
+
}
|
|
208
|
+
get modified() {
|
|
209
|
+
if (this._modified === undefined) {
|
|
210
|
+
throw new Error("Should not happen");
|
|
211
|
+
}
|
|
212
|
+
return this._modified;
|
|
213
|
+
}
|
|
214
|
+
get url() {
|
|
215
|
+
return this._url;
|
|
216
|
+
}
|
|
217
|
+
get previewUrl() {
|
|
218
|
+
return this._previewUrl;
|
|
219
|
+
}
|
|
220
|
+
stop() {
|
|
221
|
+
clearInterval(this._timerId);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
class TaskRender extends Task {
|
|
225
|
+
constructor(taskHandler, format, product, taskParams, getPreviewUrl) {
|
|
226
|
+
super(taskHandler, format, product, getPreviewUrl);
|
|
227
|
+
this.taskParams = taskParams;
|
|
228
|
+
}
|
|
229
|
+
static make(taskHandler, format, product, taskParams, getPreviewUrl) {
|
|
230
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
231
|
+
const t = new TaskRender(taskHandler, format, product, taskParams, getPreviewUrl);
|
|
232
|
+
yield t.startAndRegister();
|
|
233
|
+
return t;
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
postInit() {
|
|
237
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
return (yield this.taskHandler.api.postRender(this._productParams, Object.assign(Object.assign(Object.assign({}, this._apiSelection), this.taskParams), { format: this.format, width: Math.floor(this.taskParams.width), height: Math.floor(this.taskParams.height) }))).renderStatus;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
pollStatus() {
|
|
242
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
+
return (yield this.taskHandler.api.getRenderById({ uuid: this.uuid })).renderStatus;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
class TaskExport extends Task {
|
|
248
|
+
static make(taskHandler, format, product, getPreviewUrl) {
|
|
249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
const t = new TaskExport(taskHandler, format, product, getPreviewUrl);
|
|
251
|
+
yield t.startAndRegister();
|
|
252
|
+
return t;
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
postInit() {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
return (yield this.taskHandler.api.postExport(this._productParams, Object.assign(Object.assign({}, this._apiSelection), { format: this.format }))).exportStatus;
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
pollStatus() {
|
|
261
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
262
|
+
return (yield this.taskHandler.api.getExportById({ uuid: this.uuid })).exportStatus;
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ExportFormat, RenderFormat } from "../CatalogueAPI.js";
|
|
2
|
+
export declare type RenderOrExportFormat = RenderFormat | ExportFormat;
|
|
3
|
+
export declare function isRenderFormat(type: unknown): type is RenderFormat;
|
|
4
|
+
export declare function isExportFormat(type: unknown): type is ExportFormat;
|
|
5
|
+
//# sourceMappingURL=formats.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { exportFormatNames, renderFormatNames, } from "../CatalogueAPI.js";
|
|
2
|
+
export function isRenderFormat(type) {
|
|
3
|
+
return renderFormatNames.some((f) => type === f);
|
|
4
|
+
}
|
|
5
|
+
export function isExportFormat(type) {
|
|
6
|
+
return exportFormatNames.some((f) => type === f);
|
|
7
|
+
}
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import { CfgProduct } from "../../CfgProduct";
|
|
2
|
-
import { CfgFeature } from "../../productConfiguration/CfgFeature";
|
|
3
|
-
import { CfgOption } from "../../productConfiguration/CfgOption";
|
|
4
|
-
import { CfgProductConfiguration } from "../../productConfiguration/CfgProductConfiguration";
|
|
5
|
-
declare type SnapShotForWrapper = {
|
|
6
|
-
path: string;
|
|
7
|
-
selected: boolean;
|
|
8
|
-
};
|
|
9
|
-
declare type SnapShotForWrapperWithoutRef = SnapShotForWrapper & {
|
|
10
|
-
productConfiguration: SnapShotForConfiguration;
|
|
11
|
-
additionalProducts: SnapShotForWrapper[];
|
|
12
|
-
};
|
|
13
|
-
declare type SnapShotForWrapperWithRef = SnapShotForWrapper & {
|
|
14
|
-
ref: CfgProduct;
|
|
15
|
-
productConfiguration: SnapShotForConfigurationWithRef;
|
|
16
|
-
additionalProducts: SnapShotForWrapperWithRef[];
|
|
17
|
-
};
|
|
18
|
-
declare type SnapShotForConfiguration = {
|
|
19
|
-
path: string;
|
|
20
|
-
};
|
|
21
|
-
declare type SnapShotForConfigurationWithoutRef = SnapShotForConfiguration & {
|
|
22
|
-
features: SnapShotForFeature[];
|
|
23
|
-
};
|
|
24
|
-
declare type SnapShotForConfigurationWithRef = SnapShotForConfiguration & {
|
|
25
|
-
ref: CfgProductConfiguration;
|
|
26
|
-
features: SnapShotForFeatureWithRef[];
|
|
27
|
-
};
|
|
28
|
-
declare type SnapShotForFeature = {
|
|
29
|
-
path: string;
|
|
30
|
-
};
|
|
31
|
-
declare type SnapShotForFeatureWithoutRef = SnapShotForFeature & {
|
|
32
|
-
options: SnapShotForOption[];
|
|
33
|
-
};
|
|
34
|
-
declare type SnapShotForFeatureWithRef = SnapShotForFeature & {
|
|
35
|
-
ref: CfgFeature;
|
|
36
|
-
options: SnapShotForOptionWithRef[];
|
|
37
|
-
};
|
|
38
|
-
declare type SnapShotForOption = {
|
|
39
|
-
path: string;
|
|
40
|
-
selected: boolean;
|
|
41
|
-
};
|
|
42
|
-
declare type SnapShotForOptionWithoutRef = SnapShotForOption & {
|
|
43
|
-
features: SnapShotForFeature[];
|
|
44
|
-
};
|
|
45
|
-
declare type SnapShotForOptionWithRef = SnapShotForOption & {
|
|
46
|
-
ref: CfgOption;
|
|
47
|
-
features: SnapShotForFeatureWithRef[];
|
|
48
|
-
};
|
|
49
|
-
export declare class Collector {
|
|
50
|
-
product: CfgProduct;
|
|
51
|
-
static stripRefsForWrapper: (w: SnapShotForWrapperWithRef) => SnapShotForWrapperWithoutRef;
|
|
52
|
-
static stripRefsForConf: (c: SnapShotForConfigurationWithRef) => SnapShotForConfigurationWithoutRef;
|
|
53
|
-
static stripRefsForFeature: (f: SnapShotForFeatureWithRef) => SnapShotForFeatureWithoutRef;
|
|
54
|
-
static stripRefsForOption: (o: SnapShotForOptionWithRef) => SnapShotForOptionWithoutRef;
|
|
55
|
-
constructor(product: CfgProduct);
|
|
56
|
-
notifications: string[];
|
|
57
|
-
pushNotification: (message: string) => void;
|
|
58
|
-
takeSnapshot: () => SnapShotForWrapperWithRef;
|
|
59
|
-
compareSnapshot: (o: SnapShotForWrapperWithRef, n: SnapShotForWrapperWithRef) => string[];
|
|
60
|
-
takeRefSnapshotForWrapper: (path: string, product: CfgProduct) => SnapShotForWrapperWithRef;
|
|
61
|
-
compareSnapshotForWrapper: (result: string[], o: SnapShotForWrapperWithRef, n: SnapShotForWrapperWithRef) => void;
|
|
62
|
-
takeRefSnapshopForConf: (path: string, productConfiguration: CfgProductConfiguration) => SnapShotForConfigurationWithRef;
|
|
63
|
-
compareSnapshopForConf: (result: string[], o: SnapShotForConfigurationWithRef, n: SnapShotForConfigurationWithRef) => void;
|
|
64
|
-
takeRefSnapshotForFeature: (path: string, feature: CfgFeature) => SnapShotForFeatureWithRef;
|
|
65
|
-
compareSnapshopForFeature: (result: string[], o: SnapShotForFeatureWithRef, n: SnapShotForFeatureWithRef) => void;
|
|
66
|
-
takeRefSnapshotForOption: (path: string, option: CfgOption) => SnapShotForOptionWithRef;
|
|
67
|
-
compareSnapshopForOption: (result: string[], o: SnapShotForOptionWithRef, n: SnapShotForOptionWithRef) => void;
|
|
68
|
-
addListenersForProduct: (path: string, product: CfgProduct) => void;
|
|
69
|
-
addListenersForProductConfiguration: (path: string, productConfiguration: CfgProductConfiguration) => void;
|
|
70
|
-
addListenersForFeature: (path: string, feature: CfgFeature) => void;
|
|
71
|
-
addListenersForOption: (path: string, option: CfgOption) => void;
|
|
72
|
-
}
|
|
73
|
-
export {};
|
|
1
|
+
import { CfgProduct } from "../../CfgProduct";
|
|
2
|
+
import { CfgFeature } from "../../productConfiguration/CfgFeature";
|
|
3
|
+
import { CfgOption } from "../../productConfiguration/CfgOption";
|
|
4
|
+
import { CfgProductConfiguration } from "../../productConfiguration/CfgProductConfiguration";
|
|
5
|
+
declare type SnapShotForWrapper = {
|
|
6
|
+
path: string;
|
|
7
|
+
selected: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare type SnapShotForWrapperWithoutRef = SnapShotForWrapper & {
|
|
10
|
+
productConfiguration: SnapShotForConfiguration;
|
|
11
|
+
additionalProducts: SnapShotForWrapper[];
|
|
12
|
+
};
|
|
13
|
+
declare type SnapShotForWrapperWithRef = SnapShotForWrapper & {
|
|
14
|
+
ref: CfgProduct;
|
|
15
|
+
productConfiguration: SnapShotForConfigurationWithRef;
|
|
16
|
+
additionalProducts: SnapShotForWrapperWithRef[];
|
|
17
|
+
};
|
|
18
|
+
declare type SnapShotForConfiguration = {
|
|
19
|
+
path: string;
|
|
20
|
+
};
|
|
21
|
+
declare type SnapShotForConfigurationWithoutRef = SnapShotForConfiguration & {
|
|
22
|
+
features: SnapShotForFeature[];
|
|
23
|
+
};
|
|
24
|
+
declare type SnapShotForConfigurationWithRef = SnapShotForConfiguration & {
|
|
25
|
+
ref: CfgProductConfiguration;
|
|
26
|
+
features: SnapShotForFeatureWithRef[];
|
|
27
|
+
};
|
|
28
|
+
declare type SnapShotForFeature = {
|
|
29
|
+
path: string;
|
|
30
|
+
};
|
|
31
|
+
declare type SnapShotForFeatureWithoutRef = SnapShotForFeature & {
|
|
32
|
+
options: SnapShotForOption[];
|
|
33
|
+
};
|
|
34
|
+
declare type SnapShotForFeatureWithRef = SnapShotForFeature & {
|
|
35
|
+
ref: CfgFeature;
|
|
36
|
+
options: SnapShotForOptionWithRef[];
|
|
37
|
+
};
|
|
38
|
+
declare type SnapShotForOption = {
|
|
39
|
+
path: string;
|
|
40
|
+
selected: boolean;
|
|
41
|
+
};
|
|
42
|
+
declare type SnapShotForOptionWithoutRef = SnapShotForOption & {
|
|
43
|
+
features: SnapShotForFeature[];
|
|
44
|
+
};
|
|
45
|
+
declare type SnapShotForOptionWithRef = SnapShotForOption & {
|
|
46
|
+
ref: CfgOption;
|
|
47
|
+
features: SnapShotForFeatureWithRef[];
|
|
48
|
+
};
|
|
49
|
+
export declare class Collector {
|
|
50
|
+
product: CfgProduct;
|
|
51
|
+
static stripRefsForWrapper: (w: SnapShotForWrapperWithRef) => SnapShotForWrapperWithoutRef;
|
|
52
|
+
static stripRefsForConf: (c: SnapShotForConfigurationWithRef) => SnapShotForConfigurationWithoutRef;
|
|
53
|
+
static stripRefsForFeature: (f: SnapShotForFeatureWithRef) => SnapShotForFeatureWithoutRef;
|
|
54
|
+
static stripRefsForOption: (o: SnapShotForOptionWithRef) => SnapShotForOptionWithoutRef;
|
|
55
|
+
constructor(product: CfgProduct);
|
|
56
|
+
notifications: string[];
|
|
57
|
+
pushNotification: (message: string) => void;
|
|
58
|
+
takeSnapshot: () => SnapShotForWrapperWithRef;
|
|
59
|
+
compareSnapshot: (o: SnapShotForWrapperWithRef, n: SnapShotForWrapperWithRef) => string[];
|
|
60
|
+
takeRefSnapshotForWrapper: (path: string, product: CfgProduct) => SnapShotForWrapperWithRef;
|
|
61
|
+
compareSnapshotForWrapper: (result: string[], o: SnapShotForWrapperWithRef, n: SnapShotForWrapperWithRef) => void;
|
|
62
|
+
takeRefSnapshopForConf: (path: string, productConfiguration: CfgProductConfiguration) => SnapShotForConfigurationWithRef;
|
|
63
|
+
compareSnapshopForConf: (result: string[], o: SnapShotForConfigurationWithRef, n: SnapShotForConfigurationWithRef) => void;
|
|
64
|
+
takeRefSnapshotForFeature: (path: string, feature: CfgFeature) => SnapShotForFeatureWithRef;
|
|
65
|
+
compareSnapshopForFeature: (result: string[], o: SnapShotForFeatureWithRef, n: SnapShotForFeatureWithRef) => void;
|
|
66
|
+
takeRefSnapshotForOption: (path: string, option: CfgOption) => SnapShotForOptionWithRef;
|
|
67
|
+
compareSnapshopForOption: (result: string[], o: SnapShotForOptionWithRef, n: SnapShotForOptionWithRef) => void;
|
|
68
|
+
addListenersForProduct: (path: string, product: CfgProduct) => void;
|
|
69
|
+
addListenersForProductConfiguration: (path: string, productConfiguration: CfgProductConfiguration) => void;
|
|
70
|
+
addListenersForFeature: (path: string, feature: CfgFeature) => void;
|
|
71
|
+
addListenersForOption: (path: string, option: CfgOption) => void;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
74
|
//# sourceMappingURL=collectorForTest.d.ts.map
|