@configura/web-api 1.5.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.
Files changed (42) hide show
  1. package/dist/CatalogueAPI.d.ts +9 -2
  2. package/dist/CatalogueAPI.js +23 -0
  3. package/dist/CfgMeasure.d.ts +2 -2
  4. package/dist/CfgMeasure.js +1 -1
  5. package/dist/CfgProduct.d.ts +50 -4
  6. package/dist/CfgProduct.js +151 -17
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.js +2 -0
  9. package/dist/productConfiguration/CfgFeature.d.ts +19 -2
  10. package/dist/productConfiguration/CfgFeature.js +57 -6
  11. package/dist/productConfiguration/CfgOption.d.ts +12 -1
  12. package/dist/productConfiguration/CfgOption.js +29 -2
  13. package/dist/productConfiguration/CfgProductConfiguration.d.ts +4 -2
  14. package/dist/productConfiguration/CfgProductConfiguration.js +17 -0
  15. package/dist/productLoader.d.ts +1 -1
  16. package/dist/syncGroups/SyncGroupsApplier.d.ts +20 -0
  17. package/dist/syncGroups/SyncGroupsApplier.js +519 -0
  18. package/dist/syncGroups/SyncGroupsApplyMode.d.ts +15 -0
  19. package/dist/syncGroups/SyncGroupsApplyMode.js +15 -0
  20. package/dist/syncGroups/SyncGroupsHandler.d.ts +30 -0
  21. package/dist/syncGroups/SyncGroupsHandler.js +71 -0
  22. package/dist/syncGroups/SyncGroupsState.d.ts +20 -0
  23. package/dist/syncGroups/SyncGroupsState.js +61 -0
  24. package/dist/syncGroups/SyncGroupsTransaction.d.ts +50 -0
  25. package/dist/syncGroups/SyncGroupsTransaction.js +106 -0
  26. package/dist/tasks/TaskHandler.js +4 -3
  27. package/dist/tasks/formats.d.ts +1 -3
  28. package/dist/tasks/formats.js +3 -4
  29. package/dist/tests/testData/dummyProductForTest.d.ts +2 -2
  30. package/dist/tests/testData/dummyProductForTest.js +1 -1
  31. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +3 -3
  32. package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +27 -98
  33. package/dist/tests/testData/testDataCachedGetProduct.js +8 -19
  34. package/dist/tests/testData/testDataOptions.d.ts +13 -0
  35. package/dist/tests/testData/testDataOptions.js +60 -0
  36. package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +3 -3
  37. package/dist/tests/testData/testDataProductAggregatedPrice.js +14 -25
  38. package/dist/tests/testData/testDataUpcharge.js +16 -48
  39. package/dist/utilitiesCatalogueData.d.ts +7 -1
  40. package/dist/utilitiesCatalogueData.js +102 -0
  41. package/dist/utilitiesNumericValues.d.ts +1 -1
  42. package/package.json +3 -3
@@ -7,8 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { CfgProduct } from "../../CfgProduct";
11
- import { dummyCatId } from "./dummyProductForTest";
10
+ import { CfgProduct } from "../../CfgProduct.js";
11
+ import { dummyCatId } from "./dummyProductForTest.js";
12
+ import { letterOptionCodeA, letterOptionCodeB, letterOptionCodeC, letterOptions, } from "./testDataOptions.js";
12
13
  const A = () => ({
13
14
  uuid: "A",
14
15
  unit: "m",
@@ -18,24 +19,12 @@ const A = () => ({
18
19
  description: "",
19
20
  numericOrder: false,
20
21
  options: [
21
- {
22
- code: "optionA",
23
- description: "",
24
- additionalProductRefs: [
22
+ Object.assign(Object.assign({}, letterOptions[0]), { additionalProductRefs: [
25
23
  { refKey: "C_0", catId: dummyCatId, partNumber: "C" },
26
24
  { refKey: "B_0", catId: dummyCatId, partNumber: "B" },
27
- ],
28
- },
29
- {
30
- code: "optionB",
31
- description: "",
32
- additionalProductRefs: [{ refKey: "E", catId: dummyCatId, partNumber: "E" }],
33
- },
34
- {
35
- code: "optionC",
36
- description: "",
37
- additionalProductRefs: [{ refKey: "D", catId: dummyCatId, partNumber: "D" }],
38
- },
25
+ ] }),
26
+ Object.assign(Object.assign({}, letterOptions[1]), { additionalProductRefs: [{ refKey: "E", catId: dummyCatId, partNumber: "E" }] }),
27
+ Object.assign(Object.assign({}, letterOptions[2]), { additionalProductRefs: [{ refKey: "D", catId: dummyCatId, partNumber: "D" }] }),
39
28
  ],
40
29
  },
41
30
  ],
@@ -51,8 +40,8 @@ const A = () => ({
51
40
  {
52
41
  code: "!~!",
53
42
  next: {
54
- optionA: {
55
- code: "optionA",
43
+ [letterOptionCodeA]: {
44
+ code: letterOptionCodeA,
56
45
  },
57
46
  },
58
47
  },
@@ -150,13 +139,13 @@ export const getTestProduct = (params) => __awaiter(void 0, void 0, void 0, func
150
139
  throw new Error("No such part");
151
140
  });
152
141
  export function getSelOptions(option) {
153
- if (option === "optionB") {
142
+ if (option === letterOptionCodeB) {
154
143
  return [
155
144
  {
156
145
  code: "!~!",
157
146
  next: {
158
- optionB: {
159
- code: "optionB",
147
+ [letterOptionCodeB]: {
148
+ code: letterOptionCodeB,
160
149
  },
161
150
  },
162
151
  },
@@ -167,8 +156,8 @@ export function getSelOptions(option) {
167
156
  {
168
157
  code: "!~!",
169
158
  next: {
170
- optionC: {
171
- code: "optionC",
159
+ [letterOptionCodeC]: {
160
+ code: letterOptionCodeC,
172
161
  },
173
162
  },
174
163
  },
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { CfgProduct } from "../../CfgProduct.js";
11
11
  import { Collector } from "./collectorForTest.js";
12
12
  import { dummyCatId } from "./dummyProductForTest.js";
13
+ import { letterOptionCodeA, letterOptions } from "./testDataOptions.js";
13
14
  const Prd = () => ({
14
15
  uuid: "Prd",
15
16
  unit: "m",
@@ -19,20 +20,9 @@ const Prd = () => ({
19
20
  description: "",
20
21
  numericOrder: false,
21
22
  options: [
22
- {
23
- code: "A",
24
- description: "",
25
- },
26
- {
27
- code: "B",
28
- description: "",
29
- upcharge: undefined,
30
- },
31
- {
32
- code: "C",
33
- description: "",
34
- upcharge: 0,
35
- },
23
+ letterOptions[0],
24
+ Object.assign(Object.assign({}, letterOptions[1]), { upcharge: undefined }),
25
+ Object.assign(Object.assign({}, letterOptions[2]), { upcharge: 0 }),
36
26
  ],
37
27
  },
38
28
  {
@@ -40,20 +30,9 @@ const Prd = () => ({
40
30
  description: "",
41
31
  numericOrder: false,
42
32
  options: [
43
- {
44
- code: "A",
45
- description: "",
46
- },
47
- {
48
- code: "B",
49
- description: "",
50
- upcharge: undefined,
51
- },
52
- {
53
- code: "C",
54
- description: "",
55
- upcharge: 10,
56
- },
33
+ letterOptions[0],
34
+ Object.assign(Object.assign({}, letterOptions[1]), { upcharge: undefined }),
35
+ Object.assign(Object.assign({}, letterOptions[2]), { upcharge: 10 }),
57
36
  ],
58
37
  },
59
38
  {
@@ -62,20 +41,9 @@ const Prd = () => ({
62
41
  numericOrder: false,
63
42
  optional: true,
64
43
  options: [
65
- {
66
- code: "A",
67
- description: "",
68
- },
69
- {
70
- code: "B",
71
- description: "",
72
- upcharge: undefined,
73
- },
74
- {
75
- code: "C",
76
- description: "",
77
- upcharge: 10,
78
- },
44
+ letterOptions[0],
45
+ Object.assign(Object.assign({}, letterOptions[1]), { upcharge: undefined }),
46
+ Object.assign(Object.assign({}, letterOptions[2]), { upcharge: 10 }),
79
47
  ],
80
48
  },
81
49
  ],
@@ -91,24 +59,24 @@ const Prd = () => ({
91
59
  {
92
60
  code: "!~!",
93
61
  next: {
94
- A: {
95
- code: "A",
62
+ [letterOptionCodeA]: {
63
+ code: letterOptionCodeA,
96
64
  },
97
65
  },
98
66
  },
99
67
  {
100
68
  code: "!~!",
101
69
  next: {
102
- A: {
103
- code: "A",
70
+ [letterOptionCodeA]: {
71
+ code: letterOptionCodeA,
104
72
  },
105
73
  },
106
74
  },
107
75
  {
108
76
  code: "!~!",
109
77
  next: {
110
- A: {
111
- code: "A",
78
+ [letterOptionCodeA]: {
79
+ code: letterOptionCodeA,
112
80
  },
113
81
  },
114
82
  },
@@ -1,4 +1,4 @@
1
- import { CatalogueParams, GetProductParams, Model, PartsData, Prices, ProductData, ProductResponse, SelectedOption, ValidateResponse } from "./CatalogueAPI";
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
+ }
@@ -1,4 +1,4 @@
1
- import { CodeRange } from "./CatalogueAPI";
1
+ import { CodeRange } from "./CatalogueAPI.js";
2
2
  export declare class NumericValuesSelection {
3
3
  constructor(rawRanges: CodeRange[]);
4
4
  readonly ranges: (NumericValueRangeDefinition | NumericValueDiscrete)[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "1.5.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.5.0-alpha.0"
26
+ "@configura/web-utilities": "^1.6.1-alpha.0"
27
27
  },
28
- "gitHead": "6e24920b36ac225b17fcb519c0f4b7c6af924fbd"
28
+ "gitHead": "aa99963ec2c2e4ab4ef1795e7ad6204fef31da75"
29
29
  }