@configura/web-api 1.6.0-iotest.2 → 1.6.1-alpha.1
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/dist/CfgProduct.d.ts +29 -10
- package/dist/CfgProduct.js +82 -47
- package/dist/index.d.ts +2 -4
- package/dist/index.js +2 -4
- package/dist/productConfiguration/CfgFeature.d.ts +2 -1
- package/dist/productConfiguration/CfgFeature.js +27 -8
- package/dist/productConfiguration/CfgOption.d.ts +21 -8
- package/dist/productConfiguration/CfgOption.js +26 -18
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +1 -2
- package/dist/productConfiguration/CfgProductConfiguration.js +9 -8
- package/dist/syncGroups/SyncGroupsApplier.d.ts +20 -0
- package/dist/syncGroups/SyncGroupsApplier.js +520 -0
- package/dist/syncGroups/SyncGroupsApplyMode.d.ts +21 -0
- package/dist/syncGroups/SyncGroupsApplyMode.js +21 -0
- package/dist/syncGroups/SyncGroupsHandler.d.ts +31 -0
- package/dist/syncGroups/SyncGroupsHandler.js +71 -0
- package/dist/syncGroups/SyncGroupsPathHelper.d.ts +27 -0
- package/dist/syncGroups/SyncGroupsPathHelper.js +89 -0
- package/dist/syncGroups/SyncGroupsState.d.ts +20 -0
- package/dist/syncGroups/SyncGroupsState.js +108 -0
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +51 -0
- package/dist/syncGroups/SyncGroupsTransaction.js +100 -0
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +24 -95
- package/dist/tests/testData/testDataCachedGetProduct.js +8 -19
- package/dist/tests/testData/testDataOptions.d.ts +13 -0
- package/dist/tests/testData/testDataOptions.js +60 -0
- package/dist/tests/testData/testDataProductAggregatedPrice.js +12 -23
- package/dist/tests/testData/testDataUpcharge.js +16 -48
- package/dist/utilitiesCatalogueData.d.ts +7 -1
- package/dist/utilitiesCatalogueData.js +105 -4
- package/package.json +3 -3
- package/dist/io/CfgHistoryManager.d.ts +0 -30
- package/dist/io/CfgHistoryManager.js +0 -62
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +0 -10
- package/dist/io/CfgHistoryToProdConfConnector.js +0 -20
- package/dist/io/CfgIOManager.d.ts +0 -29
- package/dist/io/CfgIOManager.js +0 -89
- package/dist/io/CfgIOProdConfConnector.d.ts +0 -33
- package/dist/io/CfgIOProdConfConnector.js +0 -100
- package/dist/io/CfgWindowMessageManager.d.ts +0 -13
- package/dist/io/CfgWindowMessageManager.js +0 -28
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +0 -13
- package/dist/io/CfgWindowMessageToProdConfConnector.js +0 -17
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Option, SelectedOption } from "../../CatalogueAPI.js";
|
|
2
|
+
export declare function addDefaultsToMockSelectedOption(root: SelectedOption, optionCodeToAdd: string | undefined, optionCodesToRemove: string[], unlessOptionCodes: string[]): void;
|
|
3
|
+
export declare const letterOptionCodeA = "optA";
|
|
4
|
+
export declare const letterOptionCodeB = "optB";
|
|
5
|
+
export declare const letterOptionCodeC = "optC";
|
|
6
|
+
export declare const letterOptionCodeD = "optD";
|
|
7
|
+
export declare const letterOptionCodeE = "optE";
|
|
8
|
+
export declare const letterOptionCodeF = "optF";
|
|
9
|
+
export declare const letterOptions: Option[];
|
|
10
|
+
export declare const toggleOptionCodeOff = "optOff";
|
|
11
|
+
export declare const toggleOptionCodeOn = "optOn";
|
|
12
|
+
export declare const toggleOptions: Option[];
|
|
13
|
+
//# sourceMappingURL=testDataOptions.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function addDefaultsToMockSelectedOption(root, optionCodeToAdd, optionCodesToRemove, unlessOptionCodes) {
|
|
2
|
+
let next = root.next;
|
|
3
|
+
if (next === undefined) {
|
|
4
|
+
if (optionCodeToAdd === undefined) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
next = {};
|
|
8
|
+
root.next = next;
|
|
9
|
+
}
|
|
10
|
+
for (const oCode of unlessOptionCodes) {
|
|
11
|
+
if (next[oCode] !== undefined) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
for (const oCode of optionCodesToRemove) {
|
|
16
|
+
delete next[oCode];
|
|
17
|
+
}
|
|
18
|
+
if (optionCodeToAdd === undefined) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
next[optionCodeToAdd] = { code: optionCodeToAdd };
|
|
22
|
+
}
|
|
23
|
+
export const letterOptionCodeA = "optA";
|
|
24
|
+
export const letterOptionCodeB = "optB";
|
|
25
|
+
export const letterOptionCodeC = "optC";
|
|
26
|
+
export const letterOptionCodeD = "optD";
|
|
27
|
+
export const letterOptionCodeE = "optE";
|
|
28
|
+
export const letterOptionCodeF = "optF";
|
|
29
|
+
export const letterOptions = [
|
|
30
|
+
{
|
|
31
|
+
code: letterOptionCodeA,
|
|
32
|
+
description: "",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
code: letterOptionCodeB,
|
|
36
|
+
description: "",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
code: letterOptionCodeC,
|
|
40
|
+
description: "",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
code: letterOptionCodeD,
|
|
44
|
+
description: "",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
code: letterOptionCodeE,
|
|
48
|
+
description: "",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
code: letterOptionCodeF,
|
|
52
|
+
description: "",
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
export const toggleOptionCodeOff = "optOff";
|
|
56
|
+
export const toggleOptionCodeOn = "optOn";
|
|
57
|
+
export const toggleOptions = [
|
|
58
|
+
{ code: toggleOptionCodeOff, description: "" },
|
|
59
|
+
{ code: toggleOptionCodeOn, description: "" },
|
|
60
|
+
];
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { CfgProduct } from "../../CfgProduct.js";
|
|
11
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
|
-
|
|
55
|
-
code:
|
|
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 ===
|
|
142
|
+
if (option === letterOptionCodeB) {
|
|
154
143
|
return [
|
|
155
144
|
{
|
|
156
145
|
code: "!~!",
|
|
157
146
|
next: {
|
|
158
|
-
|
|
159
|
-
code:
|
|
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
|
-
|
|
171
|
-
code:
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
45
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
|
|
95
|
-
code:
|
|
62
|
+
[letterOptionCodeA]: {
|
|
63
|
+
code: letterOptionCodeA,
|
|
96
64
|
},
|
|
97
65
|
},
|
|
98
66
|
},
|
|
99
67
|
{
|
|
100
68
|
code: "!~!",
|
|
101
69
|
next: {
|
|
102
|
-
|
|
103
|
-
code:
|
|
70
|
+
[letterOptionCodeA]: {
|
|
71
|
+
code: letterOptionCodeA,
|
|
104
72
|
},
|
|
105
73
|
},
|
|
106
74
|
},
|
|
107
75
|
{
|
|
108
76
|
code: "!~!",
|
|
109
77
|
next: {
|
|
110
|
-
|
|
111
|
-
code:
|
|
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.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
|
|
@@ -2,15 +2,14 @@ import { shallowCompareDictionaries } from "@configura/web-utilities";
|
|
|
2
2
|
export const makeCatalogueKey = (cat) => `${cat.enterprise}-${cat.prdCat}-${cat.prdCatVersion}-${cat.priceList}-${cat.vendor}`;
|
|
3
3
|
export const makeProductKey = (cat, pKey) => `${makeCatalogueKey(cat)}-${pKey}`;
|
|
4
4
|
export const makeSelOptionsKey = (options) => options.reduce((p, option) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
p += `_{${code}${numericValue === undefined ? "" : `_${numericValue.value}${(_a = numericValue.unit) !== null && _a !== void 0 ? _a : ""}`}`;
|
|
5
|
+
const { code, next } = option;
|
|
6
|
+
p += "_{" + code;
|
|
8
7
|
if (next === undefined) {
|
|
9
8
|
return p;
|
|
10
9
|
}
|
|
11
10
|
for (const key of Object.keys(next)) {
|
|
12
11
|
const innerOption = next[key];
|
|
13
|
-
p +=
|
|
12
|
+
p += "_{" + key + "_" + makeSelOptionsKey([innerOption]) + "_}";
|
|
14
13
|
}
|
|
15
14
|
p += "_}";
|
|
16
15
|
return p;
|
|
@@ -63,3 +62,105 @@ export const decodeProductParams = (params) => {
|
|
|
63
62
|
const decoded = Object.assign(Object.assign({}, decodeCatalogueParams(params)), { partNumber: decodeURIComponent(params.partNumber) });
|
|
64
63
|
return decoded;
|
|
65
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.
|
|
3
|
+
"version": "1.6.1-alpha.1",
|
|
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.
|
|
26
|
+
"@configura/web-utilities": "^1.6.1-alpha.1"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "afaf1e342f0648246a1dcb6f7bc636d4d1979bec"
|
|
29
29
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { CfgIOManager } from "./CfgIOManager.js";
|
|
2
|
-
export declare type CfgHistoryManagerSendData<D> = {
|
|
3
|
-
message: D;
|
|
4
|
-
qsKeyValues: Map<string, string | undefined> | undefined;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Instantiating the class will use the history api to update your
|
|
8
|
-
* url with configuration changes
|
|
9
|
-
* Only handles configuration, not product
|
|
10
|
-
*/
|
|
11
|
-
export declare class CfgHistoryManager<D extends {
|
|
12
|
-
initial: boolean;
|
|
13
|
-
}> extends CfgIOManager<"popstate", CfgHistoryManagerSendData<D>> {
|
|
14
|
-
private readonly _useHistoryPush;
|
|
15
|
-
/**
|
|
16
|
-
* @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
|
|
17
|
-
*/
|
|
18
|
-
constructor(_useHistoryPush: boolean);
|
|
19
|
-
protected doSend(messageKey: string, data: CfgHistoryManagerSendData<D>): void;
|
|
20
|
-
private static _makeUpdatedUrl;
|
|
21
|
-
private static _makeUpdatedQueryString;
|
|
22
|
-
/**
|
|
23
|
-
* @returns The current query string as a Map
|
|
24
|
-
*/
|
|
25
|
-
static _currentQsKeyValues(): Map<string, string>;
|
|
26
|
-
private static _makeUpdatedState;
|
|
27
|
-
protected readonly eventType = "popstate";
|
|
28
|
-
protected getDataFromEvent(event: PopStateEvent): unknown;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=CfgHistoryManager.d.ts.map
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { mapQueryString, unmapQueryString } from "@configura/web-utilities";
|
|
2
|
-
import { CfgIOManager } from "./CfgIOManager.js";
|
|
3
|
-
/**
|
|
4
|
-
* Instantiating the class will use the history api to update your
|
|
5
|
-
* url with configuration changes
|
|
6
|
-
* Only handles configuration, not product
|
|
7
|
-
*/
|
|
8
|
-
export class CfgHistoryManager extends CfgIOManager {
|
|
9
|
-
/**
|
|
10
|
-
* @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
|
|
11
|
-
*/
|
|
12
|
-
constructor(_useHistoryPush) {
|
|
13
|
-
super();
|
|
14
|
-
this._useHistoryPush = _useHistoryPush;
|
|
15
|
-
this.eventType = "popstate";
|
|
16
|
-
}
|
|
17
|
-
doSend(messageKey, data) {
|
|
18
|
-
const { qsKeyValues, message } = data;
|
|
19
|
-
const newUrl = qsKeyValues === undefined ? null : CfgHistoryManager._makeUpdatedUrl(qsKeyValues);
|
|
20
|
-
const newState = CfgHistoryManager._makeUpdatedState(message, messageKey);
|
|
21
|
-
if (!message.initial && this._useHistoryPush) {
|
|
22
|
-
window.history.pushState(newState, "", newUrl);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
window.history.replaceState(newState, "", newUrl);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
static _makeUpdatedUrl(qsKeyValues) {
|
|
29
|
-
const qs = this._makeUpdatedQueryString(qsKeyValues);
|
|
30
|
-
return `${window.location.origin}${window.location.pathname}${qs ? "?" : ""}${qs}${window.location.hash}`;
|
|
31
|
-
}
|
|
32
|
-
static _makeUpdatedQueryString(qsKeyValues) {
|
|
33
|
-
const currentKeyValues = this._currentQsKeyValues();
|
|
34
|
-
for (const [key, value] of qsKeyValues) {
|
|
35
|
-
if (value === undefined) {
|
|
36
|
-
currentKeyValues.delete(key);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
currentKeyValues.set(key, value);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return unmapQueryString(currentKeyValues);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @returns The current query string as a Map
|
|
46
|
-
*/
|
|
47
|
-
static _currentQsKeyValues() {
|
|
48
|
-
return mapQueryString(window.location.search);
|
|
49
|
-
}
|
|
50
|
-
static _makeUpdatedState(message, messageKey) {
|
|
51
|
-
let messages = {};
|
|
52
|
-
const currentState = window.history.state;
|
|
53
|
-
if (CfgIOManager.isIOContainer(currentState)) {
|
|
54
|
-
messages = currentState.messages;
|
|
55
|
-
}
|
|
56
|
-
messages[messageKey] = message;
|
|
57
|
-
return CfgIOManager.makeContainer(messages);
|
|
58
|
-
}
|
|
59
|
-
getDataFromEvent(event) {
|
|
60
|
-
return event.state;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CfgHistoryManager, CfgHistoryManagerSendData } from "./CfgHistoryManager.js";
|
|
2
|
-
import { CfgIOProdConfConnector, CfgProdConfMessage } from "./CfgIOProdConfConnector.js";
|
|
3
|
-
export declare const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
4
|
-
export declare class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector<"popstate", CfgHistoryManagerSendData<CfgProdConfMessage>, CfgHistoryManager<CfgProdConfMessage>> {
|
|
5
|
-
private readonly _qsKey;
|
|
6
|
-
constructor(manager: CfgHistoryManager<CfgProdConfMessage>, _qsKey?: string, doValidate?: boolean);
|
|
7
|
-
protected getInitialProdConf(): string | undefined;
|
|
8
|
-
protected makeSendData(prodConfAsString: string, initial: boolean): CfgHistoryManagerSendData<CfgProdConfMessage>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=CfgHistoryToProdConfConnector.d.ts.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { CfgHistoryManager } from "./CfgHistoryManager.js";
|
|
2
|
-
import { CfgIOProdConfConnector } from "./CfgIOProdConfConnector.js";
|
|
3
|
-
export const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
4
|
-
export class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector {
|
|
5
|
-
constructor(manager, _qsKey = STAGE_PROD_CONF_MESSAGE_KEY, doValidate = true) {
|
|
6
|
-
super(manager, doValidate);
|
|
7
|
-
this._qsKey = _qsKey;
|
|
8
|
-
}
|
|
9
|
-
getInitialProdConf() {
|
|
10
|
-
return CfgHistoryManager._currentQsKeyValues().get(this._qsKey);
|
|
11
|
-
}
|
|
12
|
-
makeSendData(prodConfAsString, initial) {
|
|
13
|
-
return {
|
|
14
|
-
message: this.makeMessage(prodConfAsString, initial),
|
|
15
|
-
qsKeyValues: initial
|
|
16
|
-
? undefined
|
|
17
|
-
: new Map([[STAGE_PROD_CONF_MESSAGE_KEY, prodConfAsString]]),
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare type ConfiguraShebang = "c0nf1guraarug1fn0c";
|
|
2
|
-
declare type Listener = (m: unknown) => Promise<void>;
|
|
3
|
-
export declare type CfgIOContainer = {
|
|
4
|
-
shebang: ConfiguraShebang;
|
|
5
|
-
messages: {
|
|
6
|
-
[index: string]: unknown;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export declare abstract class CfgIOManager<K extends keyof WindowEventMap, S> {
|
|
10
|
-
static isIOContainer: (data: any) => data is CfgIOContainer;
|
|
11
|
-
static hasIOContainerMessageKey: (container: CfgIOContainer, messageKey: string) => boolean;
|
|
12
|
-
static getMessageFromIOContainer: (container: any, messageKey: string) => unknown;
|
|
13
|
-
static makeContainer: (messages: {
|
|
14
|
-
[index: string]: unknown;
|
|
15
|
-
}) => CfgIOContainer;
|
|
16
|
-
private _inhibitSend;
|
|
17
|
-
private _listeners;
|
|
18
|
-
private _getIndexOfListener;
|
|
19
|
-
listen: (l: Listener, messageKey: string) => void;
|
|
20
|
-
stopListen: (l: Listener) => void;
|
|
21
|
-
private _containerListenerBound;
|
|
22
|
-
protected _containerListener(event: WindowEventMap[K]): void;
|
|
23
|
-
send: (messageKey: string, data: S) => void;
|
|
24
|
-
protected abstract doSend(messageKey: string, data: S): void;
|
|
25
|
-
protected abstract readonly eventType: K;
|
|
26
|
-
protected abstract getDataFromEvent(event: WindowEventMap[K]): unknown;
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=CfgIOManager.d.ts.map
|
package/dist/io/CfgIOManager.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
const CONFIGURA_SHEBANG = "c0nf1guraarug1fn0c";
|
|
2
|
-
export class CfgIOManager {
|
|
3
|
-
constructor() {
|
|
4
|
-
// A lock to avoid circular write
|
|
5
|
-
this._inhibitSend = false;
|
|
6
|
-
this._listeners = [];
|
|
7
|
-
this._getIndexOfListener = (l) => this._listeners.findIndex((item) => l === item.l);
|
|
8
|
-
this.listen = (l, messageKey) => {
|
|
9
|
-
if (this._getIndexOfListener(l) !== -1) {
|
|
10
|
-
console.warn("Tried to add listener twice");
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const startListenToWindow = this._listeners.length === 0;
|
|
14
|
-
this._listeners.push({ l, messageKey });
|
|
15
|
-
if (startListenToWindow) {
|
|
16
|
-
window.addEventListener(this.eventType, this._containerListenerBound);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
this.stopListen = (l) => {
|
|
20
|
-
const i = this._getIndexOfListener(l);
|
|
21
|
-
if (i === -1) {
|
|
22
|
-
console.warn("Tried to stopListen on unknown listener");
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
this._listeners.splice(i, 1);
|
|
26
|
-
if (this._listeners.length === 0) {
|
|
27
|
-
window.removeEventListener(this.eventType, this._containerListenerBound);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
this._containerListenerBound = this._containerListener.bind(this);
|
|
31
|
-
this.send = (messageKey, data) => {
|
|
32
|
-
if (this._inhibitSend) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.doSend(messageKey, data);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
_containerListener(event) {
|
|
39
|
-
const data = this.getDataFromEvent(event);
|
|
40
|
-
if (!CfgIOManager.isIOContainer(data)) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
// The 15 or so rows below is one of the cases where I believe building a clever
|
|
44
|
-
// data structure of so would probably be worse for performance than just looping
|
|
45
|
-
// as the subscribers are expected to be very few
|
|
46
|
-
const listeners = this._listeners;
|
|
47
|
-
const allMessageKeys = listeners.reduce((a, c) => {
|
|
48
|
-
a.add(c.messageKey);
|
|
49
|
-
return a;
|
|
50
|
-
}, new Set());
|
|
51
|
-
this._inhibitSend = true;
|
|
52
|
-
const promises = [];
|
|
53
|
-
for (const messageKey of allMessageKeys) {
|
|
54
|
-
if (!CfgIOManager.hasIOContainerMessageKey(data, messageKey)) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const message = CfgIOManager.getMessageFromIOContainer(data, messageKey);
|
|
58
|
-
for (const item of listeners) {
|
|
59
|
-
if (item.messageKey !== messageKey) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
promises.push(item.l(message));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
Promise.all(promises)
|
|
66
|
-
.then(() => {
|
|
67
|
-
this._inhibitSend = false;
|
|
68
|
-
})
|
|
69
|
-
.catch(() => {
|
|
70
|
-
this._inhibitSend = false;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
CfgIOManager.isIOContainer = (data) => data && data.shebang === CONFIGURA_SHEBANG;
|
|
75
|
-
CfgIOManager.hasIOContainerMessageKey = (container, messageKey) => messageKey in container.messages;
|
|
76
|
-
CfgIOManager.getMessageFromIOContainer = (container, messageKey) => {
|
|
77
|
-
if (!CfgIOManager.isIOContainer(container)) {
|
|
78
|
-
throw new Error("The passed data was not a CfgIOContainer. It is to be expected that such data messages can arrive, so please use isIOContainer function to filter them out before calling this.");
|
|
79
|
-
}
|
|
80
|
-
if (!CfgIOManager.hasIOContainerMessageKey(container, messageKey)) {
|
|
81
|
-
throw new Error(`The passed data did not have the messageKey "${messageKey}". You can test for this using hasIOContainerMessageKey function.`);
|
|
82
|
-
}
|
|
83
|
-
// It is assumed that if a message arrives with the right subMessageKey it can cast to T
|
|
84
|
-
return container.messages[messageKey];
|
|
85
|
-
};
|
|
86
|
-
CfgIOManager.makeContainer = (messages) => ({
|
|
87
|
-
shebang: CONFIGURA_SHEBANG,
|
|
88
|
-
messages,
|
|
89
|
-
});
|