@configura/web-api 1.6.0-alpha.0 → 1.6.1-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.
@@ -15,7 +15,7 @@ import { CfgProductConfiguration, _CfgProductConfigurationInternal, } from "./pr
15
15
  import { collectAdditionalProductRefs } from "./productConfiguration/utilitiesProductConfiguration.js";
16
16
  import { wrapWithCache } from "./productLoader.js";
17
17
  import { SyncGroupsHandler } from "./syncGroups/SyncGroupsHandler.js";
18
- import { comparePricesObjects, correctDefaultsOnCatalogueParams, makeProductKey, } from "./utilitiesCatalogueData.js";
18
+ import { comparePricesObjects, correctDefaultsOnCatalogueParams, isSameProductRef, makeProductKey, } from "./utilitiesCatalogueData.js";
19
19
  function completeSettings(incompleteSettings) {
20
20
  var _a, _b;
21
21
  return {
@@ -357,7 +357,14 @@ export class _CfgProductInternal {
357
357
  const additionalProductRefs = [
358
358
  ...(productData.additionalProductRefs || []),
359
359
  ...collectAdditionalProductRefs(configuration),
360
- ].map((prodRef, originalIndex) => ({
360
+ ]
361
+ .reduce((a, c) => {
362
+ if (a.every((p) => !isSameProductRef(p, c))) {
363
+ a.push(c);
364
+ }
365
+ return a;
366
+ }, [])
367
+ .map((prodRef, originalIndex) => ({
361
368
  prodRef,
362
369
  originalIndex,
363
370
  }));
@@ -104,7 +104,8 @@ class SyncStateOnto {
104
104
  // what you did chose should be immediately visible. With SyncGroups the end result
105
105
  // is the combination of potentially many different validate calls, and so errors
106
106
  // could accumulate and what is cause and effect be hard to know.
107
- if (revalidationResults.some((r) => r.wasAborted || !r.requestDidValidate)) {
107
+ if (!revalidationResults.every((r) => r.requestDidValidate) ||
108
+ revalidationResults.every((r) => r.wasAborted)) {
108
109
  transaction.abort();
109
110
  return false;
110
111
  }
@@ -1,4 +1,4 @@
1
- import { CatalogueParams, GetProductParams, Model, PartsData, Prices, ProductData, ProductResponse, SelectedOption, ValidateResponse } from "./CatalogueAPI.js";
1
+ import { AdditionalProductRef, CatalogueParams, GetProductParams, MeasureParam, Model, Orientation, PartsData, Prices, ProductData, ProductResponse, SelectedOption, Transform, ValidateResponse, Vector } from "./CatalogueAPI.js";
2
2
  export declare const makeCatalogueKey: (cat: CatalogueParams) => string;
3
3
  export declare const makeProductKey: (cat: CatalogueParams, pKey: string) => string;
4
4
  export declare const makeSelOptionsKey: (options: SelectedOption[]) => string;
@@ -23,4 +23,10 @@ export declare function recursivelyGetPriceCodeValue(priceCodes: string[], price
23
23
  export declare function comparePricesObjects(prices1: Prices | undefined, prices2: Prices | undefined): boolean;
24
24
  export declare const decodeCatalogueParams: <T extends CatalogueParams>(params: T) => T;
25
25
  export declare const decodeProductParams: <T extends GetProductParams>(params: T) => T;
26
+ export declare function isSameCatalogueParams(left: CatalogueParams, right: CatalogueParams): boolean;
27
+ export declare function isSameVector(left: Vector, right: Vector): boolean;
28
+ export declare function isSameOrientation(left: Orientation, right: Orientation): boolean;
29
+ export declare function isSameAnchor(left: MeasureParam, right: MeasureParam): boolean;
30
+ export declare function isSameTransform(left: Transform, right: Transform): boolean;
31
+ export declare function isSameProductRef(left: AdditionalProductRef, right: AdditionalProductRef): boolean;
26
32
  //# sourceMappingURL=utilitiesCatalogueData.d.ts.map
@@ -62,3 +62,105 @@ export const decodeProductParams = (params) => {
62
62
  const decoded = Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) });
63
63
  return decoded;
64
64
  };
65
+ export function isSameCatalogueParams(left, right) {
66
+ return (left.enterprise === right.enterprise &&
67
+ left.prdCat === right.prdCat &&
68
+ left.prdCatVersion === right.prdCatVersion &&
69
+ left.priceList === right.priceList &&
70
+ left.vendor === right.vendor);
71
+ }
72
+ export function isSameVector(left, right) {
73
+ return left.x === right.x && left.y === right.y && left.z === right.z;
74
+ }
75
+ export function isSameOrientation(left, right) {
76
+ return left.pitch === right.pitch && left.roll === right.roll && left.yaw === right.yaw;
77
+ }
78
+ export function isSameAnchor(left, right) {
79
+ var _a, _b;
80
+ if (left.code !== right.code) {
81
+ return false;
82
+ }
83
+ if (left.anchorPoint !== right.anchorPoint) {
84
+ return false;
85
+ }
86
+ const leftMeasurePriorities = (_a = left.measurePriority) !== null && _a !== void 0 ? _a : [];
87
+ const rightMeasurePriorities = (_b = right.measurePriority) !== null && _b !== void 0 ? _b : [];
88
+ if (leftMeasurePriorities.length !== rightMeasurePriorities.length) {
89
+ return false;
90
+ }
91
+ if (leftMeasurePriorities.some((p, i) => p.url !== rightMeasurePriorities[i].url)) {
92
+ return false;
93
+ }
94
+ return true;
95
+ }
96
+ export function isSameTransform(left, right) {
97
+ const leftTransformPos = left.pos;
98
+ const rightTransformPos = right.pos;
99
+ const leftTransformRot = left.rot;
100
+ const rightTransformRot = right.rot;
101
+ const leftTransformScale = left.scale;
102
+ const rightTransformScale = right.scale;
103
+ if ((leftTransformPos === undefined) !== (rightTransformPos === undefined)) {
104
+ return false;
105
+ }
106
+ if ((leftTransformRot === undefined) !== (rightTransformRot === undefined)) {
107
+ return false;
108
+ }
109
+ if ((leftTransformScale === undefined) !== (rightTransformScale === undefined)) {
110
+ return false;
111
+ }
112
+ if (leftTransformPos !== undefined &&
113
+ rightTransformPos !== undefined &&
114
+ !isSameVector(leftTransformPos, rightTransformPos)) {
115
+ return false;
116
+ }
117
+ if (leftTransformRot !== undefined &&
118
+ rightTransformRot !== undefined &&
119
+ !isSameOrientation(leftTransformRot, rightTransformRot)) {
120
+ return false;
121
+ }
122
+ if (leftTransformScale !== undefined &&
123
+ rightTransformScale !== undefined &&
124
+ !isSameVector(leftTransformScale, rightTransformScale)) {
125
+ return false;
126
+ }
127
+ return true;
128
+ }
129
+ export function isSameProductRef(left, right) {
130
+ if (left.refKey !== right.refKey) {
131
+ return false;
132
+ }
133
+ if (!isSameCatalogueParams(left.catId, right.catId)) {
134
+ return false;
135
+ }
136
+ if (left.partNumber !== right.partNumber) {
137
+ return false;
138
+ }
139
+ if (left.refDescription !== right.refDescription) {
140
+ return false;
141
+ }
142
+ const leftAnchor = left.anchor;
143
+ const rightAnchor = right.anchor;
144
+ if ((leftAnchor === undefined) !== (rightAnchor === undefined)) {
145
+ return false;
146
+ }
147
+ if (leftAnchor !== undefined &&
148
+ rightAnchor !== undefined &&
149
+ !isSameAnchor(leftAnchor, rightAnchor)) {
150
+ return false;
151
+ }
152
+ const leftTransform = left.transform;
153
+ const rightTransform = right.transform;
154
+ if ((leftTransform === undefined) !== (rightTransform === undefined)) {
155
+ return false;
156
+ }
157
+ if (leftTransform !== undefined &&
158
+ rightTransform !== undefined &&
159
+ !isSameTransform(leftTransform, rightTransform)) {
160
+ return false;
161
+ }
162
+ if (left.optional !== right.optional) {
163
+ return false;
164
+ }
165
+ return true;
166
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "1.6.0-alpha.0",
3
+ "version": "1.6.1-alpha.0",
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": "^1.6.0-alpha.0"
26
+ "@configura/web-utilities": "^1.6.1-alpha.0"
27
27
  },
28
- "gitHead": "f099cebca376c87c4743a8e9b1c4f1ceaee0c888"
28
+ "gitHead": "aa99963ec2c2e4ab4ef1795e7ad6204fef31da75"
29
29
  }