@configura/web-api 2.0.0-alpha.6 → 2.0.0-alpha.9

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.
@@ -5,6 +5,11 @@ export interface DtoAdditionalProductConfiguration {
5
5
  selOptions: Array<DtoSelectedOption>;
6
6
  additionalProducts?: Array<DtoAdditionalProductConfiguration>;
7
7
  }
8
+ /** AdditionalProductConfigurationV2 */
9
+ export interface DtoAdditionalProductConfigurationV2 extends DtoProductConfiguration {
10
+ refKey: string;
11
+ selected: boolean;
12
+ }
8
13
  /** AdditionalProductRef */
9
14
  export interface DtoAdditionalProductRef {
10
15
  refKey: string;
@@ -22,7 +27,7 @@ export interface DtoApplicationArea {
22
27
  material?: string;
23
28
  preview?: string;
24
29
  }
25
- /** DtoApplicationAreasResponse */
30
+ /** ApplicationAreasResponse */
26
31
  export interface DtoApplicationAreasResponse {
27
32
  applicationAreas: Array<DtoApplicationArea>;
28
33
  uuid: string;
@@ -74,31 +79,6 @@ export interface DtoCodeRange {
74
79
  maxValue: number;
75
80
  increment?: number;
76
81
  }
77
- /** ConfAddProd */
78
- export interface DtoConfAddProd extends DtoConfProd {
79
- refKey: string;
80
- selected: boolean;
81
- }
82
- /** ConfFeature */
83
- export interface DtoConfFeature {
84
- code: string;
85
- groupCode?: string;
86
- unit?: string;
87
- options?: Array<DtoConfOption>;
88
- }
89
- /** ConfOption */
90
- export interface DtoConfOption {
91
- code: string;
92
- selected: boolean;
93
- numericValue?: DtoValueWithUnit;
94
- features?: Array<DtoConfFeature>;
95
- }
96
- /** ConfProd */
97
- export interface DtoConfProd {
98
- features?: Array<DtoConfFeature>;
99
- additionalProducts?: Array<DtoConfAddProd>;
100
- prodParams?: DtoProductParamsWithLang;
101
- }
102
82
  /** ErrorResponse */
103
83
  export interface DtoErrorResponse {
104
84
  error: string;
@@ -147,6 +127,13 @@ export interface DtoFeature {
147
127
  syncGroup?: DtoSyncGroup;
148
128
  unit?: string;
149
129
  }
130
+ /** FeatureConfiguration */
131
+ export interface DtoFeatureConfiguration {
132
+ code: string;
133
+ groupCode?: string;
134
+ unit?: string;
135
+ options?: Array<DtoOptionConfiguration>;
136
+ }
150
137
  /** FeatureRef */
151
138
  export interface DtoFeatureRef {
152
139
  code: string;
@@ -176,7 +163,7 @@ export interface DtoGetPriceListsParams {
176
163
  vendor: string;
177
164
  priceList: string;
178
165
  }
179
- /** DtoProductParamsWithLang represents the URL parameters of getProduct */
166
+ /** GetProductParams represents the URL parameters of getProduct */
180
167
  export interface DtoGetProductParams {
181
168
  lang: string;
182
169
  enterprise: string;
@@ -261,6 +248,13 @@ export interface DtoOption {
261
248
  upcharge?: number;
262
249
  priceCodes?: Array<string>;
263
250
  }
251
+ /** OptionConfiguration */
252
+ export interface DtoOptionConfiguration {
253
+ code: string;
254
+ selected: boolean;
255
+ numericValue?: DtoValueWithUnit;
256
+ features?: Array<DtoFeatureConfiguration>;
257
+ }
264
258
  /** Orientation */
265
259
  export interface DtoOrientation {
266
260
  yaw: number;
@@ -359,6 +353,12 @@ export interface DtoProductCatalogueInfo {
359
353
  exchangeRate: number;
360
354
  lastModified: string;
361
355
  }
356
+ /** ProductConfiguration */
357
+ export interface DtoProductConfiguration {
358
+ features?: Array<DtoFeatureConfiguration>;
359
+ additionalProducts?: Array<DtoAdditionalProductConfigurationV2>;
360
+ prodParams?: DtoProductParamsWithLang;
361
+ }
362
362
  /** ProductData */
363
363
  export interface DtoProductData {
364
364
  area?: string;
@@ -9,28 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10
10
  });
11
11
  };
12
- export const dtoExportFormatNames = [
13
- "glb",
14
- "gltf",
15
- "fbx",
16
- "dwg",
17
- "cmdrw",
18
- "cmfav",
19
- "cmsym",
20
- ];
21
- export const dtoExportStatusStatusNames = [
22
- "pending",
23
- "running",
24
- "finished",
25
- "failed",
26
- ];
12
+ export const dtoExportFormatNames = ["glb", "gltf", "fbx", "dwg", "cmdrw", "cmfav", "cmsym"];
13
+ export const dtoExportStatusStatusNames = ["pending", "running", "finished", "failed"];
27
14
  export const dtoRenderFormatNames = ["jpg", "png"];
28
- export const dtoRenderStatusStatusNames = [
29
- "pending",
30
- "running",
31
- "finished",
32
- "failed",
33
- ];
15
+ export const dtoRenderStatusStatusNames = ["pending", "running", "finished", "failed"];
34
16
  export const dtoSyncGroupMethodsNames = ["pull", "push", "twoWay"];
35
17
  export class DtoAPIError extends Error {
36
18
  }
@@ -49,9 +31,7 @@ export class CatalogueAPI {
49
31
  }
50
32
  }
51
33
  hasFeature(feature) {
52
- return (this.auth !== undefined &&
53
- this.auth.apiSession.features !== undefined &&
54
- this.auth.apiSession.features.indexOf(feature) > -1);
34
+ return this.auth !== undefined && this.auth.apiSession.features !== undefined && this.auth.apiSession.features.indexOf(feature) > -1;
55
35
  }
56
36
  fetch(url, options) {
57
37
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,5 +1,5 @@
1
1
  import { AggregatedLoadingObservable, LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParams, DtoConfProd, DtoMeasureParam, DtoMtrlApplication, DtoPrices, DtoProductParamsWithLang, DtoTransform } from "./CatalogueAPI.js";
2
+ import { DtoAdditionalProductConfiguration, DtoAdditionalProductRef, DtoCatalogueParams, DtoMeasureParam, DtoMtrlApplication, DtoPrices, DtoProductConfiguration, DtoProductParamsWithLang, DtoTransform } from "./CatalogueAPI.js";
3
3
  import { CfgMeasureDefinition } from "./CfgMeasure.js";
4
4
  import { _CfgFeatureInternal } from "./productConfiguration/CfgFeature.js";
5
5
  import { ProductConfigurationBubbleMode } from "./productConfiguration/CfgOption.js";
@@ -136,8 +136,8 @@ export declare class _CfgProductInternal {
136
136
  _additionalProductHasChanged: (freshRef: CfgProduct, bubbleMode: CfgProductBubbleMode, committed: boolean) => Promise<void>;
137
137
  /** Called by the configuration to tell its parent that it has changed. */
138
138
  _configurationHasChanged: (freshRef: CfgProductConfiguration, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
139
- getDtoConf: (includeExtendedData: boolean, includeProductParams: boolean) => DtoConfProd;
140
- setDtoConf: (s: DtoConfProd, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
139
+ getDtoConf: (includeExtendedData: boolean, includeProductParams: boolean) => DtoProductConfiguration;
140
+ setDtoConf: (s: DtoProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
141
141
  setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
142
142
  copyFrom: (source: _CfgProductInternal, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
143
143
  private _setApiSelectionWithOtherProduct;
@@ -256,8 +256,8 @@ export declare class CfgProduct {
256
256
  * selections on a product is needed, such as when doing Render or Export.
257
257
  */
258
258
  getApiSelection: () => DtoAdditionalProductConfiguration;
259
- getDtoConf: (includeExtendedData?: boolean, includeProductParams?: boolean) => DtoConfProd;
260
- setDtoConf: (s: DtoConfProd, doValidate?: boolean) => Promise<boolean>;
259
+ getDtoConf: (includeExtendedData?: boolean, includeProductParams?: boolean) => DtoProductConfiguration;
260
+ setDtoConf: (s: DtoProductConfiguration, doValidate?: boolean) => Promise<boolean>;
261
261
  setApiSelection: (s: DtoAdditionalProductConfiguration, doValidate?: boolean) => Promise<boolean>;
262
262
  listenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
263
263
  stopListenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
@@ -598,13 +598,12 @@ prodParams, settings, optional, loadingObservable, parent, root, additionalProdu
598
598
  const productResponse = yield productLoaderForGroupedLoad.getProduct(correctDefaultsOnCatalogueParams(prodParams));
599
599
  const { productData, rootFeatureRefs, features: allRawFeatures, uuid, unit, } = productResponse;
600
600
  const product = yield new Promise((initSuccess, initFail) => {
601
- var _a;
602
601
  const p = new _CfgProductInternal(() => {
603
602
  // We absolutely do not want anyone to assign to this._configuration. So we want that field private.
604
603
  // But we can not set the api selection synchronously. And the product configuration needs "this". So we use this callback.
605
604
  // Feel free to find a nicer more readable solution :)
606
605
  initSuccess(p);
607
- }, initFail, productLoaderRaw, prodParams, settings, optional, !optional, rootFeatureRefs, allRawFeatures, uuid, unit, productData, (_a = productData.partsData.selOptions) !== null && _a !== void 0 ? _a : [], loadingObservable, parent, root, additionalProductRef, syncGroupHandler);
606
+ }, initFail, productLoaderRaw, prodParams, settings, optional, !optional, rootFeatureRefs, allRawFeatures, uuid, unit, productData, productData.partsData.selOptions || [], loadingObservable, parent, root, additionalProductRef, syncGroupHandler);
608
607
  });
609
608
  yield product._syncAndLoadAdditionalProducts(productLoaderForGroupedLoad);
610
609
  // Product is guaranteed to be root
@@ -8,7 +8,20 @@ import { DtoCatalogueParamsWithLang, DtoProductParamsWithLang } from "./Catalogu
8
8
  * Internally at Configura we try to stick with this format.
9
9
  */
10
10
  export declare class CfgReferencePathHelper {
11
+ /**
12
+ * Use to generate URLs in our reference format. This is the format Configura uses in our integrations.
13
+ * @param browsingRootUrl The URL where Stage browsing begins
14
+ * @param catParams What catalogue to generate URL for.
15
+ * @returns An URL to a catalogue
16
+ */
11
17
  static getCataloguePath: (browsingRootUrl: string, catParams: DtoCatalogueParamsWithLang) => string;
12
- static getProductPath: (browsingRootUrl: string, productParams: DtoProductParamsWithLang) => string;
18
+ /**
19
+ * Use to generate URLs in our reference format. This is the format Configura uses in our integrations.
20
+ * @param browsingRootUrl The URL where Stage browsing begins
21
+ * @param productParams What product to generate URL for.
22
+ * @param separator Optional, defaults to "product", but can be changed to indicate another function.
23
+ * @returns An URL to a product
24
+ */
25
+ static getProductPath: (browsingRootUrl: string, productParams: DtoProductParamsWithLang, separator?: string) => string;
13
26
  }
14
27
  //# sourceMappingURL=CfgReferencePathHelper.d.ts.map
@@ -9,5 +9,18 @@ import { encodeURIComponents } from "@configura/web-utilities";
9
9
  */
10
10
  export class CfgReferencePathHelper {
11
11
  }
12
+ /**
13
+ * Use to generate URLs in our reference format. This is the format Configura uses in our integrations.
14
+ * @param browsingRootUrl The URL where Stage browsing begins
15
+ * @param catParams What catalogue to generate URL for.
16
+ * @returns An URL to a catalogue
17
+ */
12
18
  CfgReferencePathHelper.getCataloguePath = (browsingRootUrl, catParams) => `${browsingRootUrl}/${encodeURIComponents(catParams.cid, catParams.lang, catParams.enterprise, catParams.prdCat, catParams.prdCatVersion, catParams.vendor, catParams.priceList)}`;
13
- CfgReferencePathHelper.getProductPath = (browsingRootUrl, productParams) => `${CfgReferencePathHelper.getCataloguePath(browsingRootUrl, productParams)}/product/${encodeURIComponent(productParams.partNumber)}`;
19
+ /**
20
+ * Use to generate URLs in our reference format. This is the format Configura uses in our integrations.
21
+ * @param browsingRootUrl The URL where Stage browsing begins
22
+ * @param productParams What product to generate URL for.
23
+ * @param separator Optional, defaults to "product", but can be changed to indicate another function.
24
+ * @returns An URL to a product
25
+ */
26
+ CfgReferencePathHelper.getProductPath = (browsingRootUrl, productParams, separator = "product") => `${CfgReferencePathHelper.getCataloguePath(browsingRootUrl, productParams)}/${separator}/${encodeURIComponent(productParams.partNumber)}`;
@@ -1,5 +1,5 @@
1
- import { DtoAdditionalProductConfiguration, DtoConfAddProd, DtoConfFeature, DtoConfProd, DtoSelectedOption } from "./CatalogueAPI.js";
2
- export declare const isDtoConfProdAdditional: (value: DtoConfProd) => value is DtoConfAddProd;
3
- export declare const convertDtoConfProdToV1: (conf: DtoConfProd, silenceWarnings?: boolean) => DtoAdditionalProductConfiguration;
4
- export declare const convertDtoConfFeaturesToSelOptions: (features: DtoConfFeature[], silenceWarnings?: boolean) => DtoSelectedOption[];
1
+ import { DtoAdditionalProductConfiguration, DtoAdditionalProductConfigurationV2, DtoFeatureConfiguration, DtoProductConfiguration, DtoSelectedOption } from "./CatalogueAPI.js";
2
+ export declare const isDtoConfProdAdditional: (value: DtoProductConfiguration) => value is DtoAdditionalProductConfigurationV2;
3
+ export declare const convertDtoConfProdToV1: (conf: DtoProductConfiguration, silenceWarnings?: boolean) => DtoAdditionalProductConfiguration;
4
+ export declare const convertDtoConfFeaturesToSelOptions: (features: DtoFeatureConfiguration[], silenceWarnings?: boolean) => DtoSelectedOption[];
5
5
  //# sourceMappingURL=ConfigurationConverter.d.ts.map
@@ -4,28 +4,19 @@ declare type CfgHistoryManagerMessageData = {
4
4
  };
5
5
  /**
6
6
  * The collected data used when sending. For history this both contains the message, which is
7
- * used as the "state" in the history-frame, and the qsKeyValues, which are used in the URL.
7
+ * used as the "state" in the history-frame, and the qsKeyValues, which are query string
8
+ * key-values used in the URL.
8
9
  * When navigating back and forth the stage (message) is used to restore the old state. When
9
10
  * opening a window with no prior history the Query String will be used.
10
11
  */
11
12
  export declare type CfgHistoryManagerSendData<D> = {
12
13
  message: D;
13
- historyWriteMode: CfgHistoryWriteMode;
14
+ useHistoryPush: boolean;
14
15
  qsKeyValues: Map<string, string | undefined>;
15
16
  };
16
17
  /**
17
- * @param Replace Just updates the URL
18
- * @param Push Push makes the web browser navigation buttons navigate configuration changes.
19
- * @param DoNotWrite Do not update the history at all.
20
- */
21
- export declare enum CfgHistoryWriteMode {
22
- Replace = "Replace",
23
- Push = "Push",
24
- DoNotWrite = "DoNotWrite"
25
- }
26
- /**
27
- * This class does nothing on it's own. It is used to coordinate writing to the history, that
28
- * is, updating the browsing history.
18
+ * This class is used to coordinate writing and reading to the browser history.
19
+ * It handles messages sent from the connectors.
29
20
  */
30
21
  export declare class CfgHistoryManager extends CfgWindowEventManager<"popstate", CfgHistoryManagerSendData<CfgHistoryManagerMessageData>> {
31
22
  private static _instance;
@@ -2,19 +2,8 @@ import { mapQueryString, unmapQueryString } from "@configura/web-utilities";
2
2
  import { CfgIOManager } from "./CfgIOManager.js";
3
3
  import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
4
4
  /**
5
- * @param Replace Just updates the URL
6
- * @param Push Push makes the web browser navigation buttons navigate configuration changes.
7
- * @param DoNotWrite Do not update the history at all.
8
- */
9
- export var CfgHistoryWriteMode;
10
- (function (CfgHistoryWriteMode) {
11
- CfgHistoryWriteMode["Replace"] = "Replace";
12
- CfgHistoryWriteMode["Push"] = "Push";
13
- CfgHistoryWriteMode["DoNotWrite"] = "DoNotWrite";
14
- })(CfgHistoryWriteMode || (CfgHistoryWriteMode = {}));
15
- /**
16
- * This class does nothing on it's own. It is used to coordinate writing to the history, that
17
- * is, updating the browsing history.
5
+ * This class is used to coordinate writing and reading to the browser history.
6
+ * It handles messages sent from the connectors.
18
7
  */
19
8
  export class CfgHistoryManager extends CfgWindowEventManager {
20
9
  constructor() {
@@ -31,17 +20,14 @@ export class CfgHistoryManager extends CfgWindowEventManager {
31
20
  * Write to the history
32
21
  */
33
22
  send(messageKey, data) {
34
- const { qsKeyValues, message, historyWriteMode } = data;
35
- if (historyWriteMode === CfgHistoryWriteMode.DoNotWrite) {
36
- return;
37
- }
23
+ const { qsKeyValues, message, useHistoryPush } = data;
38
24
  // Initial data is before user interaction has happened
39
25
  const initial = message.initial;
40
26
  // At initial we do not replace the URL as we presumable have the defaults
41
27
  const newUrl = initial ? null : CfgHistoryManager._makeUpdatedUrl(qsKeyValues);
42
28
  // ...but we do replace the state so that we can in the future browse back to here
43
29
  const newState = CfgHistoryManager._makeUpdatedState(window.history.state, message, messageKey);
44
- if (initial || historyWriteMode === CfgHistoryWriteMode.Replace || this.receiveInProgress) {
30
+ if (initial || !useHistoryPush || this.receiveInProgress) {
45
31
  window.history.replaceState(newState, "", newUrl);
46
32
  }
47
33
  else {
@@ -1,21 +1,21 @@
1
- import { DtoConfProd } from "../CatalogueAPI.js";
2
- import { CfgHistoryManager, CfgHistoryManagerSendData, CfgHistoryWriteMode } from "./CfgHistoryManager.js";
1
+ import { DtoProductConfiguration } from "../CatalogueAPI.js";
2
+ import { CfgHistoryManager, CfgHistoryManagerSendData } from "./CfgHistoryManager.js";
3
3
  import { CfgIOProdConfConnector, CfgProdConfMessage } from "./CfgIOProdConfConnector.js";
4
- export declare function dtoConfToString(conf: DtoConfProd): string;
5
- export declare function stringToDtoConf(conf: string): DtoConfProd;
4
+ export declare function dtoConfToString(conf: DtoProductConfiguration): string;
5
+ export declare function stringToDtoConf(conf: string): DtoProductConfiguration;
6
6
  /**
7
7
  * Instantiating this will make the browser history (and URL) update with the product configuration.
8
8
  */
9
9
  export declare class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector<CfgHistoryManagerSendData<CfgProdConfMessage>> {
10
- private readonly _historyWriteMode;
10
+ private readonly _useHistoryPush;
11
11
  private readonly _qsKey;
12
12
  /**
13
- * @param _historyWriteMode What way to update history.
13
+ * @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
14
14
  * @param _qsKey The Query String key for product configuration.
15
15
  * @param doValidate When popping from the history stack (navigating in the browser), should a navigate call be sent to the server to verify that the product configuration is still valid?
16
16
  */
17
- constructor(manager: CfgHistoryManager, _historyWriteMode: CfgHistoryWriteMode, _qsKey?: string, doValidate?: boolean);
18
- protected getInitialProdConf(): DtoConfProd | undefined;
19
- protected makeSendData(conf: DtoConfProd, initial: boolean): CfgHistoryManagerSendData<CfgProdConfMessage>;
17
+ constructor(manager: CfgHistoryManager, _useHistoryPush: boolean, _qsKey?: string, doValidate?: boolean);
18
+ protected getInitialProdConf(): DtoProductConfiguration | undefined;
19
+ protected makeSendData(conf: DtoProductConfiguration, initial: boolean): CfgHistoryManagerSendData<CfgProdConfMessage>;
20
20
  }
21
21
  //# sourceMappingURL=CfgHistoryToProdConfConnector.d.ts.map
@@ -1,4 +1,4 @@
1
- import { CfgHistoryManager, } from "./CfgHistoryManager.js";
1
+ import { CfgHistoryManager } from "./CfgHistoryManager.js";
2
2
  import { CfgIOProdConfConnector, CfgProdConfMessageVersions, STAGE_PROD_CONF_MESSAGE_KEY, } from "./CfgIOProdConfConnector.js";
3
3
  const jsonKeyRegex = /"([^"]+)":/g;
4
4
  const keyMap = [
@@ -30,13 +30,13 @@ export function stringToDtoConf(conf) {
30
30
  */
31
31
  export class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector {
32
32
  /**
33
- * @param _historyWriteMode What way to update history.
33
+ * @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
34
34
  * @param _qsKey The Query String key for product configuration.
35
35
  * @param doValidate When popping from the history stack (navigating in the browser), should a navigate call be sent to the server to verify that the product configuration is still valid?
36
36
  */
37
- constructor(manager, _historyWriteMode, _qsKey = STAGE_PROD_CONF_MESSAGE_KEY, doValidate = true) {
38
- super(manager, doValidate, CfgProdConfMessageVersions.V2dot0, false, false);
39
- this._historyWriteMode = _historyWriteMode;
37
+ constructor(manager, _useHistoryPush, _qsKey = STAGE_PROD_CONF_MESSAGE_KEY, doValidate = true) {
38
+ super(manager, doValidate, false, false);
39
+ this._useHistoryPush = _useHistoryPush;
40
40
  this._qsKey = _qsKey;
41
41
  }
42
42
  getInitialProdConf() {
@@ -48,9 +48,9 @@ export class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector {
48
48
  }
49
49
  makeSendData(conf, initial) {
50
50
  return {
51
- message: this.makeMessage(conf, initial),
51
+ message: CfgIOProdConfConnector.makeMessage(conf, initial, CfgProdConfMessageVersions.V2dot0),
52
52
  qsKeyValues: new Map([[STAGE_PROD_CONF_MESSAGE_KEY, dtoConfToString(conf)]]),
53
- historyWriteMode: this._historyWriteMode,
53
+ useHistoryPush: this._useHistoryPush,
54
54
  };
55
55
  }
56
56
  }
@@ -1,4 +1,4 @@
1
- import { DtoAdditionalProductConfiguration, DtoConfProd } from "../CatalogueAPI.js";
1
+ import { DtoAdditionalProductConfiguration, DtoProductConfiguration } from "../CatalogueAPI.js";
2
2
  import { CfgProduct, CfgProductChangeNotification } from "../CfgProduct.js";
3
3
  import { CfgIOManager } from "./CfgIOManager.js";
4
4
  export declare const isCfgProdConfMessage: (data: unknown) => data is CfgProdConfMessageV1 | CfgProdConfMessageV2;
@@ -9,7 +9,7 @@ export declare type CfgProdConfMessageV1 = {
9
9
  export declare const isCfgProdConfMessageV1: (data: unknown) => data is CfgProdConfMessageV1;
10
10
  export declare type CfgProdConfMessageV2 = {
11
11
  version: "2.0";
12
- conf: DtoConfProd;
12
+ conf: DtoProductConfiguration;
13
13
  };
14
14
  export declare const isCfgProdConfMessageV2: (data: unknown) => data is CfgProdConfMessageV2;
15
15
  export declare type CfgProdConfMessage = {
@@ -23,35 +23,34 @@ export declare enum CfgProdConfMessageVersions {
23
23
  }
24
24
  export declare const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
25
25
  declare type ProdConfMessageCallback = (message: CfgProdConfMessage) => Promise<void>;
26
- declare type ProdConfCallback = (conf: DtoConfProd) => Promise<void>;
26
+ declare type ProdConfCallback = (conf: DtoProductConfiguration) => Promise<void>;
27
27
  /**
28
28
  * Base class for connecting the product configuration to an IO channel
29
29
  */
30
30
  export declare abstract class CfgIOProdConfConnector<S> {
31
31
  private readonly _ioManager;
32
32
  private readonly _doValidate;
33
- private readonly _sendVersions;
34
33
  private readonly _includeExtendedDataInSend;
35
34
  private readonly _includeProdParamsInSend;
36
35
  private _product;
37
36
  private _stopListenToMessage;
38
37
  private _stopListenToProdConf;
39
- constructor(_ioManager: CfgIOManager<S>, _doValidate: boolean, _sendVersions: CfgProdConfMessageVersions, _includeExtendedDataInSend: boolean, // Only v2.0
38
+ constructor(_ioManager: CfgIOManager<S>, _doValidate: boolean, _includeExtendedDataInSend: boolean, // Only v2.0
40
39
  _includeProdParamsInSend: boolean);
41
40
  destroy: () => void;
42
41
  setProduct: (product: CfgProduct | undefined) => Promise<void>;
43
42
  private _send;
44
- protected getInitialProdConf(): DtoConfProd | undefined;
45
- protected abstract makeSendData(conf: DtoConfProd, initial: boolean): S;
46
- makeMessage(conf: DtoConfProd, initial: boolean): CfgProdConfMessage;
47
- makeMessageListener(callback: ProdConfMessageCallback): (message: unknown) => Promise<void>;
43
+ protected getInitialProdConf(): DtoProductConfiguration | undefined;
44
+ protected abstract makeSendData(conf: DtoProductConfiguration, initial: boolean): S;
45
+ static makeMessage(conf: DtoProductConfiguration, initial: boolean, sendVersions: CfgProdConfMessageVersions): CfgProdConfMessage;
46
+ static makeMessageListener(callback: ProdConfMessageCallback): (message: unknown) => Promise<void>;
48
47
  /**
49
48
  * Register the callback to listen for Product Configuration messages
50
49
  * @returns A function which when called will cancel listening
51
50
  */
52
- listenForMessage(callback: ProdConfMessageCallback): () => void;
53
- makeProdConfListener(callback: ProdConfCallback): (n: CfgProductChangeNotification) => void;
54
- listenForProdConf(product: CfgProduct, callback: ProdConfCallback): () => void;
51
+ static listenForMessage<S>(callback: ProdConfMessageCallback, ioManager: CfgIOManager<S>): () => void;
52
+ static makeProdConfListener(callback: ProdConfCallback, includeExtendedDataInSend: boolean, includeProdParamsInSend: boolean): (n: CfgProductChangeNotification) => void;
53
+ static listenForProdConf(product: CfgProduct, callback: ProdConfCallback, includeExtendedDataInSend: boolean, includeProdParamsInSend: boolean): () => void;
55
54
  }
56
55
  export {};
57
56
  //# sourceMappingURL=CfgIOProdConfConnector.d.ts.map
@@ -24,12 +24,11 @@ export const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
24
24
  * Base class for connecting the product configuration to an IO channel
25
25
  */
26
26
  export class CfgIOProdConfConnector {
27
- constructor(_ioManager, _doValidate, _sendVersions, _includeExtendedDataInSend, // Only v2.0
27
+ constructor(_ioManager, _doValidate, _includeExtendedDataInSend, // Only v2.0
28
28
  _includeProdParamsInSend // Only v2.0
29
29
  ) {
30
30
  this._ioManager = _ioManager;
31
31
  this._doValidate = _doValidate;
32
- this._sendVersions = _sendVersions;
33
32
  this._includeExtendedDataInSend = _includeExtendedDataInSend;
34
33
  this._includeProdParamsInSend = _includeProdParamsInSend;
35
34
  this._stopListenToMessage = undefined;
@@ -65,7 +64,7 @@ export class CfgIOProdConfConnector {
65
64
  }
66
65
  }
67
66
  this._send(this.makeSendData(newProduct.getDtoConf(this._includeExtendedDataInSend, this._includeProdParamsInSend), true));
68
- this._stopListenToMessage = this.listenForMessage((messages) => __awaiter(this, void 0, void 0, function* () {
67
+ this._stopListenToMessage = CfgIOProdConfConnector.listenForMessage((messages) => __awaiter(this, void 0, void 0, function* () {
69
68
  const subMessages = messages.subMessages;
70
69
  if (subMessages.length === 0) {
71
70
  console.warn(`${STAGE_PROD_CONF_MESSAGE_KEY} message without any submessages. Unexpected.`);
@@ -81,17 +80,17 @@ export class CfgIOProdConfConnector {
81
80
  return;
82
81
  }
83
82
  throw new Error("Unknown message version");
84
- }));
85
- this._stopListenToProdConf = this.listenForProdConf(newProduct, (conf) => __awaiter(this, void 0, void 0, function* () { return this._send(this.makeSendData(conf, false)); }));
83
+ }), this._ioManager);
84
+ this._stopListenToProdConf = CfgIOProdConfConnector.listenForProdConf(newProduct, (conf) => __awaiter(this, void 0, void 0, function* () { return this._send(this.makeSendData(conf, false)); }), this._includeExtendedDataInSend, this._includeProdParamsInSend);
86
85
  });
87
86
  this._send = (data) => this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, data);
88
87
  }
89
88
  getInitialProdConf() {
90
89
  return undefined;
91
90
  }
92
- makeMessage(conf, initial) {
91
+ static makeMessage(conf, initial, sendVersions) {
93
92
  const result = [];
94
- if ((this._sendVersions & CfgProdConfMessageVersions.V1dot0) ===
93
+ if ((sendVersions & CfgProdConfMessageVersions.V1dot0) ===
95
94
  CfgProdConfMessageVersions.V1dot0) {
96
95
  const v1 = {
97
96
  version: "1.0",
@@ -99,7 +98,7 @@ export class CfgIOProdConfConnector {
99
98
  };
100
99
  result.push(v1);
101
100
  }
102
- if ((this._sendVersions & CfgProdConfMessageVersions.V2dot0) ===
101
+ if ((sendVersions & CfgProdConfMessageVersions.V2dot0) ===
103
102
  CfgProdConfMessageVersions.V2dot0) {
104
103
  const v2 = {
105
104
  version: "2.0",
@@ -109,7 +108,7 @@ export class CfgIOProdConfConnector {
109
108
  }
110
109
  return { subMessages: result, initial };
111
110
  }
112
- makeMessageListener(callback) {
111
+ static makeMessageListener(callback) {
113
112
  return (message) => __awaiter(this, void 0, void 0, function* () {
114
113
  const prodConfMessage = message;
115
114
  yield callback(prodConfMessage);
@@ -119,24 +118,23 @@ export class CfgIOProdConfConnector {
119
118
  * Register the callback to listen for Product Configuration messages
120
119
  * @returns A function which when called will cancel listening
121
120
  */
122
- listenForMessage(callback) {
123
- const ioManager = this._ioManager;
121
+ static listenForMessage(callback, ioManager) {
124
122
  const listener = this.makeMessageListener(callback);
125
123
  ioManager.listenForMessage(listener, STAGE_PROD_CONF_MESSAGE_KEY);
126
124
  return () => {
127
125
  ioManager.stopListenForMessage(listener);
128
126
  };
129
127
  }
130
- makeProdConfListener(callback) {
128
+ static makeProdConfListener(callback, includeExtendedDataInSend, includeProdParamsInSend) {
131
129
  return (n) => {
132
130
  if (!n.committed) {
133
131
  return;
134
132
  }
135
- callback(n.freshRef.getDtoConf(this._includeExtendedDataInSend, this._includeProdParamsInSend));
133
+ callback(n.freshRef.getDtoConf(includeExtendedDataInSend, includeProdParamsInSend));
136
134
  };
137
135
  }
138
- listenForProdConf(product, callback) {
139
- const listener = this.makeProdConfListener(callback);
136
+ static listenForProdConf(product, callback, includeExtendedDataInSend, includeProdParamsInSend) {
137
+ const listener = this.makeProdConfListener(callback, includeExtendedDataInSend, includeProdParamsInSend);
140
138
  product.listenForChange(listener);
141
139
  return () => {
142
140
  product.stopListenForChange(listener);
@@ -1,5 +1,9 @@
1
1
  import { Observable } from "@configura/web-utilities";
2
2
  import { CfgIOManager, IOManagerListener } from "./CfgIOManager.js";
3
+ /**
4
+ * This class is used to coordinate sending and receiving using the observable
5
+ * state in the class. It handles messages sent from the connectors.
6
+ */
3
7
  export declare class CfgObservableStateManager extends CfgIOManager<unknown> {
4
8
  private static _instance;
5
9
  static get instance(): CfgObservableStateManager;
@@ -1,5 +1,9 @@
1
1
  import { Observable } from "@configura/web-utilities";
2
2
  import { CfgIOManager } from "./CfgIOManager.js";
3
+ /**
4
+ * This class is used to coordinate sending and receiving using the observable
5
+ * state in the class. It handles messages sent from the connectors.
6
+ */
3
7
  export class CfgObservableStateManager extends CfgIOManager {
4
8
  constructor() {
5
9
  super();
@@ -1,4 +1,4 @@
1
- import { DtoConfProd } from "../CatalogueAPI.js";
1
+ import { DtoProductConfiguration } from "../CatalogueAPI.js";
2
2
  import { CfgIOProdConfConnector, CfgProdConfMessage, CfgProdConfMessageVersions } from "./CfgIOProdConfConnector.js";
3
3
  import { CfgObservableStateManager } from "./CfgObservableStateManager.js";
4
4
  /**
@@ -9,7 +9,8 @@ import { CfgObservableStateManager } from "./CfgObservableStateManager.js";
9
9
  * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
10
10
  */
11
11
  export declare class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector<CfgProdConfMessage> {
12
- constructor(manager: CfgObservableStateManager, doValidate?: boolean, sendVersions?: CfgProdConfMessageVersions, includeExtendedDataInSend?: boolean, includeProdParamsInSend?: boolean);
13
- protected makeSendData(conf: DtoConfProd, initial: boolean): CfgProdConfMessage;
12
+ private _sendVersions;
13
+ constructor(manager: CfgObservableStateManager, doValidate?: boolean, _sendVersions?: CfgProdConfMessageVersions, includeExtendedDataInSend?: boolean, includeProdParamsInSend?: boolean);
14
+ protected makeSendData(conf: DtoProductConfiguration, initial: boolean): CfgProdConfMessage;
14
15
  }
15
16
  //# sourceMappingURL=CfgObservableStateToProdConfConnector.d.ts.map
@@ -7,10 +7,11 @@ import { CfgIOProdConfConnector, CfgProdConfMessageVersions, } from "./CfgIOProd
7
7
  * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
8
8
  */
9
9
  export class CfgObservableStateToProdConfConnector extends CfgIOProdConfConnector {
10
- constructor(manager, doValidate = true, sendVersions = CfgProdConfMessageVersions.V2dot0, includeExtendedDataInSend = false, includeProdParamsInSend = false) {
11
- super(manager, doValidate, sendVersions, includeExtendedDataInSend, includeProdParamsInSend);
10
+ constructor(manager, doValidate = true, _sendVersions = CfgProdConfMessageVersions.V2dot0, includeExtendedDataInSend = false, includeProdParamsInSend = false) {
11
+ super(manager, doValidate, includeExtendedDataInSend, includeProdParamsInSend);
12
+ this._sendVersions = _sendVersions;
12
13
  }
13
14
  makeSendData(conf, initial) {
14
- return this.makeMessage(conf, initial);
15
+ return CfgIOProdConfConnector.makeMessage(conf, initial, this._sendVersions);
15
16
  }
16
17
  }
@@ -1,8 +1,8 @@
1
1
  import { IOManagerListener } from "./CfgIOManager.js";
2
2
  import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
3
3
  /**
4
- * This class does nothing on it's own. It is used to coordinate sending and receiving
5
- * using the post message-API. See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
4
+ * This class is used to coordinate sending and receiving using the post message-API.
5
+ * See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
6
6
  */
7
7
  export declare class CfgWindowMessageManager extends CfgWindowEventManager<"message", unknown> {
8
8
  private static _instance;
@@ -1,8 +1,8 @@
1
1
  import { CfgIOManager } from "./CfgIOManager.js";
2
2
  import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
3
3
  /**
4
- * This class does nothing on it's own. It is used to coordinate sending and receiving
5
- * using the post message-API. See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
4
+ * This class is used to coordinate sending and receiving using the post message-API.
5
+ * See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
6
6
  */
7
7
  export class CfgWindowMessageManager extends CfgWindowEventManager {
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { DtoConfProd } from "../CatalogueAPI.js";
1
+ import { DtoProductConfiguration } from "../CatalogueAPI.js";
2
2
  import { CfgIOProdConfConnector, CfgProdConfMessage, CfgProdConfMessageVersions } from "./CfgIOProdConfConnector.js";
3
3
  import { CfgWindowMessageManager } from "./CfgWindowMessageManager.js";
4
4
  /**
@@ -11,7 +11,8 @@ import { CfgWindowMessageManager } from "./CfgWindowMessageManager.js";
11
11
  * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
12
12
  */
13
13
  export declare class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector<CfgProdConfMessage> {
14
- constructor(manager: CfgWindowMessageManager, doValidate?: boolean, sendVersions?: CfgProdConfMessageVersions, includeExtendedDataInSend?: boolean, includeProdParamsInSend?: boolean);
15
- protected makeSendData(conf: DtoConfProd, initial: boolean): CfgProdConfMessage;
14
+ private _sendVersions;
15
+ constructor(manager: CfgWindowMessageManager, doValidate?: boolean, _sendVersions?: CfgProdConfMessageVersions, includeExtendedDataInSend?: boolean, includeProdParamsInSend?: boolean);
16
+ protected makeSendData(conf: DtoProductConfiguration, initial: boolean): CfgProdConfMessage;
16
17
  }
17
18
  //# sourceMappingURL=CfgWindowMessageToProdConfConnector.d.ts.map
@@ -9,10 +9,11 @@ import { CfgIOProdConfConnector, CfgProdConfMessageVersions, } from "./CfgIOProd
9
9
  * @param includeProdParamsInSend Only for version 2.0. Includes product params, in both main and additional products.
10
10
  */
11
11
  export class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector {
12
- constructor(manager, doValidate = true, sendVersions = CfgProdConfMessageVersions.V2dot0, includeExtendedDataInSend = false, includeProdParamsInSend = false) {
13
- super(manager, doValidate, sendVersions, includeExtendedDataInSend, includeProdParamsInSend);
12
+ constructor(manager, doValidate = true, _sendVersions = CfgProdConfMessageVersions.V2dot0, includeExtendedDataInSend = false, includeProdParamsInSend = false) {
13
+ super(manager, doValidate, includeExtendedDataInSend, includeProdParamsInSend);
14
+ this._sendVersions = _sendVersions;
14
15
  }
15
16
  makeSendData(conf, initial) {
16
- return this.makeMessage(conf, initial);
17
+ return CfgIOProdConfConnector.makeMessage(conf, initial, this._sendVersions);
17
18
  }
18
19
  }
@@ -1,5 +1,5 @@
1
1
  import { LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { DtoConfFeature, DtoFeature, DtoSelectedOption, DtoSyncGroup, DtoSyncGroupMethods } from "../CatalogueAPI.js";
2
+ import { DtoFeature, DtoFeatureConfiguration, DtoSelectedOption, DtoSyncGroup, DtoSyncGroupMethods } from "../CatalogueAPI.js";
3
3
  import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
4
4
  import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
5
5
  import { SyncCode } from "../syncGroups/SyncGroupsHandler.js";
@@ -99,7 +99,7 @@ export declare class _CfgFeatureInternal {
99
99
  * as nonexisting children can not call their parent.
100
100
  */
101
101
  _childHasChanged: (childOption: _CfgOptionInternal, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
102
- getDtoConf: (includeExtendedData: boolean) => DtoConfFeature;
102
+ getDtoConf: (includeExtendedData: boolean) => DtoFeatureConfiguration;
103
103
  setApiSelection: (apiOptionSelectionMap: {
104
104
  [index: string]: DtoSelectedOption;
105
105
  } | undefined) => Promise<boolean>;
@@ -1,5 +1,5 @@
1
1
  import { LengthUnit, Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { DtoConfOption, DtoFeature, DtoOption, DtoSelectedOption } from "../CatalogueAPI.js";
2
+ import { DtoFeature, DtoOption, DtoOptionConfiguration, DtoSelectedOption } from "../CatalogueAPI.js";
3
3
  import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
4
4
  import { CfgMtrlApplication } from "../material/CfgMtrlApplication.js";
5
5
  import { NumericValuesSelection } from "../utilitiesNumericValues.js";
@@ -89,7 +89,7 @@ export declare class _CfgOptionInternal {
89
89
  get features(): CfgFeature[];
90
90
  /** Called by child to tell its parent that it has changed. */
91
91
  _childHasChanged: (freshRef: CfgFeature, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
92
- getDtoConf: (includeExtendedData: boolean) => DtoConfOption;
92
+ getDtoConf: (includeExtendedData: boolean) => DtoOptionConfiguration;
93
93
  setApiSelection: (apiOptionSelection: DtoSelectedOption | undefined) => Promise<boolean>;
94
94
  structureCompare: (other: _CfgOptionInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
95
95
  tryMatchSelection: (other: CfgOption, descriptionMatch?: boolean) => Promise<boolean>;
@@ -1,5 +1,5 @@
1
1
  import { LengthUnit, LengthValue, Observable, SingleArgCallback } from "@configura/web-utilities";
2
- import { DtoConfFeature, DtoFeature, DtoFeatureRef, DtoSelectedOption } from "../CatalogueAPI.js";
2
+ import { DtoFeature, DtoFeatureConfiguration, DtoFeatureRef, DtoSelectedOption } from "../CatalogueAPI.js";
3
3
  import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js";
4
4
  import { CfgFeature, _CfgFeatureInternal } from "./CfgFeature.js";
5
5
  import { ProductConfigurationBubbleMode } from "./CfgOption.js";
@@ -34,7 +34,7 @@ export declare class _CfgProductConfigurationInternal {
34
34
  _freshRefDescendants(): void;
35
35
  /** Called by child to tell its parent that it has changed. */
36
36
  _childHasChanged: (freshRef: CfgFeature, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
37
- getDtoConf: (includeExtendedData: boolean) => DtoConfFeature[];
37
+ getDtoConf: (includeExtendedData: boolean) => DtoFeatureConfiguration[];
38
38
  /**
39
39
  * When used internally the notifications are taken care off by the caller, but if set from
40
40
  * outside we want notifications to bubble all the way to the root.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.9",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@configura/web-utilities": "2.0.0-alpha.6"
26
+ "@configura/web-utilities": "2.0.0-alpha.9"
27
27
  },
28
- "gitHead": "91edc6834460f70904b9914292a5869ad6e8b245"
28
+ "gitHead": "734f4e65f7d3dc9836c5c0321dbe6c36bbfa2531"
29
29
  }