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