@rkmodules/rules 0.0.111 → 0.0.112

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 CHANGED
@@ -1880,12 +1880,118 @@ var groupAll = {
1880
1880
  }); },
1881
1881
  };
1882
1882
 
1883
+ var normalizeTree = {
1884
+ name: "normalizeTree",
1885
+ label: "Normalize Groups",
1886
+ description: "Normalize a tree to consequtive groups and removed empty groups.",
1887
+ inputs: {
1888
+ tree: "any",
1889
+ },
1890
+ outputs: {
1891
+ tree: "any",
1892
+ },
1893
+ impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
1894
+ var normalized;
1895
+ return __generator(this, function (_a) {
1896
+ if (!inputs.tree) {
1897
+ return [2 /*return*/, {}];
1898
+ }
1899
+ normalized = normalizePaths(inputs.tree);
1900
+ return [2 /*return*/, {
1901
+ tree: mapTreeBranch(normalized, function (branch) {
1902
+ if (!branch.length) {
1903
+ return DISCARD;
1904
+ }
1905
+ return branch;
1906
+ }),
1907
+ }];
1908
+ });
1909
+ }); },
1910
+ };
1911
+
1912
+ var filterTree = {
1913
+ name: "filterTree",
1914
+ label: "Filter Tree",
1915
+ description: "Filter groups by path matchers",
1916
+ inputs: {
1917
+ tree: "any",
1918
+ query: { type: "string", default: "*" },
1919
+ },
1920
+ outputs: {
1921
+ tree: "any",
1922
+ },
1923
+ impl: function (inputs, params) { return __awaiter(void 0, void 0, void 0, function () {
1924
+ var queries;
1925
+ return __generator(this, function (_a) {
1926
+ queries = toArray(inputs.query || {}).map(function (q) {
1927
+ return q
1928
+ .trim()
1929
+ .split(";")
1930
+ .map(function (part) {
1931
+ return new RegExp("^" + part.replace(/\*/g, ".*") + "$");
1932
+ });
1933
+ });
1934
+ return [2 /*return*/, {
1935
+ tree: mapTreeBranch(inputs.tree || {}, function (branch, path) {
1936
+ var pathSegments = path.split(";");
1937
+ var match = queries.some(function (query) {
1938
+ return query.every(function (regex, i) {
1939
+ if (!regex.test(pathSegments[i] || "")) {
1940
+ return false;
1941
+ }
1942
+ return true;
1943
+ });
1944
+ });
1945
+ if (match) {
1946
+ return branch;
1947
+ }
1948
+ else {
1949
+ return DISCARD;
1950
+ }
1951
+ }),
1952
+ }];
1953
+ });
1954
+ }); },
1955
+ };
1956
+
1957
+ var treeItem = {
1958
+ name: "treeItem",
1959
+ label: "Tree Item",
1960
+ description: "Retrieve the groups from a tree at specified indexes",
1961
+ inputs: {
1962
+ tree: "any",
1963
+ index: { type: "number", default: 0 },
1964
+ },
1965
+ outputs: {
1966
+ tree: "any",
1967
+ },
1968
+ impl: function (inputs, params) { return __awaiter(void 0, void 0, void 0, function () {
1969
+ var indices;
1970
+ return __generator(this, function (_a) {
1971
+ indices = toArray(inputs.index || {});
1972
+ return [2 /*return*/, {
1973
+ tree: mapTreeBranch(inputs.tree || {}, function (branch, path, index) {
1974
+ if (indices.includes(index)) {
1975
+ return branch;
1976
+ }
1977
+ else {
1978
+ return DISCARD;
1979
+ }
1980
+ }),
1981
+ }];
1982
+ });
1983
+ }); },
1984
+ };
1985
+
1883
1986
  var _a$4;
1884
1987
  var primitives$4 = (_a$4 = {},
1885
1988
  _a$4[splitGroup.name] = splitGroup,
1886
1989
  _a$4[mergeGroup.name] = mergeGroup,
1887
1990
  _a$4[groupAll.name] = groupAll,
1991
+ _a$4[filterTree.name] = filterTree,
1992
+ _a$4[treeItem.name] = treeItem,
1888
1993
  _a$4[simplifyTree.name] = simplifyTree,
1994
+ _a$4[normalizeTree.name] = normalizeTree,
1889
1995
  _a$4[cartesianGroups.name] = cartesianGroups,
1890
1996
  _a$4[mergeTree.name] = mergeTree,
1891
1997
  _a$4);