@rkmodules/rules 0.0.111 → 0.0.113
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/index.cjs.js +116 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +116 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/DataTree/index.d.ts +1 -0
- package/dist/lib/Primitives/Group/filterTree.d.ts +2 -0
- package/dist/lib/Primitives/Group/normalizeTree.d.ts +2 -0
- package/dist/lib/Primitives/Group/treeItem.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -236,6 +236,12 @@ function isTree(value) {
|
|
|
236
236
|
Object.keys(value).length > 0 &&
|
|
237
237
|
Object.values(value).every(function (v) { return Array.isArray(v); }));
|
|
238
238
|
}
|
|
239
|
+
function isEmptyTree(value) {
|
|
240
|
+
return (typeof value === "object" &&
|
|
241
|
+
value !== null &&
|
|
242
|
+
!Array.isArray(value) &&
|
|
243
|
+
Object.keys(value).length === 0);
|
|
244
|
+
}
|
|
239
245
|
function isSingleTon(value) {
|
|
240
246
|
return (Object.keys(value).length === 1 && Object.values(value)[0].length === 1);
|
|
241
247
|
}
|
|
@@ -252,6 +258,9 @@ function broadCast(value) {
|
|
|
252
258
|
if (isTree(value)) {
|
|
253
259
|
return value;
|
|
254
260
|
}
|
|
261
|
+
if (isEmptyTree(value)) {
|
|
262
|
+
return {};
|
|
263
|
+
}
|
|
255
264
|
return { "0": [value] };
|
|
256
265
|
}
|
|
257
266
|
function getBranch(tree, path) {
|
|
@@ -1880,12 +1889,118 @@ var groupAll = {
|
|
|
1880
1889
|
}); },
|
|
1881
1890
|
};
|
|
1882
1891
|
|
|
1892
|
+
var normalizeTree = {
|
|
1893
|
+
name: "normalizeTree",
|
|
1894
|
+
label: "Normalize Groups",
|
|
1895
|
+
description: "Normalize a tree to consequtive groups and removed empty groups.",
|
|
1896
|
+
inputs: {
|
|
1897
|
+
tree: "any",
|
|
1898
|
+
},
|
|
1899
|
+
outputs: {
|
|
1900
|
+
tree: "any",
|
|
1901
|
+
},
|
|
1902
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1903
|
+
var normalized;
|
|
1904
|
+
return __generator(this, function (_a) {
|
|
1905
|
+
if (!inputs.tree) {
|
|
1906
|
+
return [2 /*return*/, {}];
|
|
1907
|
+
}
|
|
1908
|
+
normalized = normalizePaths(inputs.tree);
|
|
1909
|
+
return [2 /*return*/, {
|
|
1910
|
+
tree: mapTreeBranch(normalized, function (branch) {
|
|
1911
|
+
if (!branch.length) {
|
|
1912
|
+
return DISCARD;
|
|
1913
|
+
}
|
|
1914
|
+
return branch;
|
|
1915
|
+
}),
|
|
1916
|
+
}];
|
|
1917
|
+
});
|
|
1918
|
+
}); },
|
|
1919
|
+
};
|
|
1920
|
+
|
|
1921
|
+
var filterTree = {
|
|
1922
|
+
name: "filterTree",
|
|
1923
|
+
label: "Filter Tree",
|
|
1924
|
+
description: "Filter groups by path matchers",
|
|
1925
|
+
inputs: {
|
|
1926
|
+
tree: "any",
|
|
1927
|
+
query: { type: "string", default: "*" },
|
|
1928
|
+
},
|
|
1929
|
+
outputs: {
|
|
1930
|
+
tree: "any",
|
|
1931
|
+
},
|
|
1932
|
+
impl: function (inputs, params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1933
|
+
var queries;
|
|
1934
|
+
return __generator(this, function (_a) {
|
|
1935
|
+
queries = toArray(inputs.query || {}).map(function (q) {
|
|
1936
|
+
return q
|
|
1937
|
+
.trim()
|
|
1938
|
+
.split(";")
|
|
1939
|
+
.map(function (part) {
|
|
1940
|
+
return new RegExp("^" + part.replace(/\*/g, ".*") + "$");
|
|
1941
|
+
});
|
|
1942
|
+
});
|
|
1943
|
+
return [2 /*return*/, {
|
|
1944
|
+
tree: mapTreeBranch(inputs.tree || {}, function (branch, path) {
|
|
1945
|
+
var pathSegments = path.split(";");
|
|
1946
|
+
var match = queries.some(function (query) {
|
|
1947
|
+
return query.every(function (regex, i) {
|
|
1948
|
+
if (!regex.test(pathSegments[i] || "")) {
|
|
1949
|
+
return false;
|
|
1950
|
+
}
|
|
1951
|
+
return true;
|
|
1952
|
+
});
|
|
1953
|
+
});
|
|
1954
|
+
if (match) {
|
|
1955
|
+
return branch;
|
|
1956
|
+
}
|
|
1957
|
+
else {
|
|
1958
|
+
return DISCARD;
|
|
1959
|
+
}
|
|
1960
|
+
}),
|
|
1961
|
+
}];
|
|
1962
|
+
});
|
|
1963
|
+
}); },
|
|
1964
|
+
};
|
|
1965
|
+
|
|
1966
|
+
var treeItem = {
|
|
1967
|
+
name: "treeItem",
|
|
1968
|
+
label: "Tree Item",
|
|
1969
|
+
description: "Retrieve the groups from a tree at specified indexes",
|
|
1970
|
+
inputs: {
|
|
1971
|
+
tree: "any",
|
|
1972
|
+
index: { type: "number", default: 0 },
|
|
1973
|
+
},
|
|
1974
|
+
outputs: {
|
|
1975
|
+
tree: "any",
|
|
1976
|
+
},
|
|
1977
|
+
impl: function (inputs, params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1978
|
+
var indices;
|
|
1979
|
+
return __generator(this, function (_a) {
|
|
1980
|
+
indices = toArray(inputs.index || {});
|
|
1981
|
+
return [2 /*return*/, {
|
|
1982
|
+
tree: mapTreeBranch(inputs.tree || {}, function (branch, path, index) {
|
|
1983
|
+
if (indices.includes(index)) {
|
|
1984
|
+
return branch;
|
|
1985
|
+
}
|
|
1986
|
+
else {
|
|
1987
|
+
return DISCARD;
|
|
1988
|
+
}
|
|
1989
|
+
}),
|
|
1990
|
+
}];
|
|
1991
|
+
});
|
|
1992
|
+
}); },
|
|
1993
|
+
};
|
|
1994
|
+
|
|
1883
1995
|
var _a$4;
|
|
1884
1996
|
var primitives$4 = (_a$4 = {},
|
|
1885
1997
|
_a$4[splitGroup.name] = splitGroup,
|
|
1886
1998
|
_a$4[mergeGroup.name] = mergeGroup,
|
|
1887
1999
|
_a$4[groupAll.name] = groupAll,
|
|
2000
|
+
_a$4[filterTree.name] = filterTree,
|
|
2001
|
+
_a$4[treeItem.name] = treeItem,
|
|
1888
2002
|
_a$4[simplifyTree.name] = simplifyTree,
|
|
2003
|
+
_a$4[normalizeTree.name] = normalizeTree,
|
|
1889
2004
|
_a$4[cartesianGroups.name] = cartesianGroups,
|
|
1890
2005
|
_a$4[mergeTree.name] = mergeTree,
|
|
1891
2006
|
_a$4);
|
|
@@ -7485,6 +7600,7 @@ exports.getVariable = getVariable;
|
|
|
7485
7600
|
exports.graftTree = graftTree;
|
|
7486
7601
|
exports.hasReference = hasReference;
|
|
7487
7602
|
exports.interpolate = interpolate;
|
|
7603
|
+
exports.isEmptyTree = isEmptyTree;
|
|
7488
7604
|
exports.isReference = isReference;
|
|
7489
7605
|
exports.isSingleTon = isSingleTon;
|
|
7490
7606
|
exports.isTree = isTree;
|