@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.esm.js CHANGED
@@ -234,6 +234,12 @@ function isTree(value) {
234
234
  Object.keys(value).length > 0 &&
235
235
  Object.values(value).every(function (v) { return Array.isArray(v); }));
236
236
  }
237
+ function isEmptyTree(value) {
238
+ return (typeof value === "object" &&
239
+ value !== null &&
240
+ !Array.isArray(value) &&
241
+ Object.keys(value).length === 0);
242
+ }
237
243
  function isSingleTon(value) {
238
244
  return (Object.keys(value).length === 1 && Object.values(value)[0].length === 1);
239
245
  }
@@ -250,6 +256,9 @@ function broadCast(value) {
250
256
  if (isTree(value)) {
251
257
  return value;
252
258
  }
259
+ if (isEmptyTree(value)) {
260
+ return {};
261
+ }
253
262
  return { "0": [value] };
254
263
  }
255
264
  function getBranch(tree, path) {
@@ -1878,12 +1887,118 @@ var groupAll = {
1878
1887
  }); },
1879
1888
  };
1880
1889
 
1890
+ var normalizeTree = {
1891
+ name: "normalizeTree",
1892
+ label: "Normalize Groups",
1893
+ description: "Normalize a tree to consequtive groups and removed empty groups.",
1894
+ inputs: {
1895
+ tree: "any",
1896
+ },
1897
+ outputs: {
1898
+ tree: "any",
1899
+ },
1900
+ impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
1901
+ var normalized;
1902
+ return __generator(this, function (_a) {
1903
+ if (!inputs.tree) {
1904
+ return [2 /*return*/, {}];
1905
+ }
1906
+ normalized = normalizePaths(inputs.tree);
1907
+ return [2 /*return*/, {
1908
+ tree: mapTreeBranch(normalized, function (branch) {
1909
+ if (!branch.length) {
1910
+ return DISCARD;
1911
+ }
1912
+ return branch;
1913
+ }),
1914
+ }];
1915
+ });
1916
+ }); },
1917
+ };
1918
+
1919
+ var filterTree = {
1920
+ name: "filterTree",
1921
+ label: "Filter Tree",
1922
+ description: "Filter groups by path matchers",
1923
+ inputs: {
1924
+ tree: "any",
1925
+ query: { type: "string", default: "*" },
1926
+ },
1927
+ outputs: {
1928
+ tree: "any",
1929
+ },
1930
+ impl: function (inputs, params) { return __awaiter(void 0, void 0, void 0, function () {
1931
+ var queries;
1932
+ return __generator(this, function (_a) {
1933
+ queries = toArray(inputs.query || {}).map(function (q) {
1934
+ return q
1935
+ .trim()
1936
+ .split(";")
1937
+ .map(function (part) {
1938
+ return new RegExp("^" + part.replace(/\*/g, ".*") + "$");
1939
+ });
1940
+ });
1941
+ return [2 /*return*/, {
1942
+ tree: mapTreeBranch(inputs.tree || {}, function (branch, path) {
1943
+ var pathSegments = path.split(";");
1944
+ var match = queries.some(function (query) {
1945
+ return query.every(function (regex, i) {
1946
+ if (!regex.test(pathSegments[i] || "")) {
1947
+ return false;
1948
+ }
1949
+ return true;
1950
+ });
1951
+ });
1952
+ if (match) {
1953
+ return branch;
1954
+ }
1955
+ else {
1956
+ return DISCARD;
1957
+ }
1958
+ }),
1959
+ }];
1960
+ });
1961
+ }); },
1962
+ };
1963
+
1964
+ var treeItem = {
1965
+ name: "treeItem",
1966
+ label: "Tree Item",
1967
+ description: "Retrieve the groups from a tree at specified indexes",
1968
+ inputs: {
1969
+ tree: "any",
1970
+ index: { type: "number", default: 0 },
1971
+ },
1972
+ outputs: {
1973
+ tree: "any",
1974
+ },
1975
+ impl: function (inputs, params) { return __awaiter(void 0, void 0, void 0, function () {
1976
+ var indices;
1977
+ return __generator(this, function (_a) {
1978
+ indices = toArray(inputs.index || {});
1979
+ return [2 /*return*/, {
1980
+ tree: mapTreeBranch(inputs.tree || {}, function (branch, path, index) {
1981
+ if (indices.includes(index)) {
1982
+ return branch;
1983
+ }
1984
+ else {
1985
+ return DISCARD;
1986
+ }
1987
+ }),
1988
+ }];
1989
+ });
1990
+ }); },
1991
+ };
1992
+
1881
1993
  var _a$4;
1882
1994
  var primitives$4 = (_a$4 = {},
1883
1995
  _a$4[splitGroup.name] = splitGroup,
1884
1996
  _a$4[mergeGroup.name] = mergeGroup,
1885
1997
  _a$4[groupAll.name] = groupAll,
1998
+ _a$4[filterTree.name] = filterTree,
1999
+ _a$4[treeItem.name] = treeItem,
1886
2000
  _a$4[simplifyTree.name] = simplifyTree,
2001
+ _a$4[normalizeTree.name] = normalizeTree,
1887
2002
  _a$4[cartesianGroups.name] = cartesianGroups,
1888
2003
  _a$4[mergeTree.name] = mergeTree,
1889
2004
  _a$4);
@@ -7461,5 +7576,5 @@ function DDContext(_a) {
7461
7576
  return React.createElement(DndProvider, { backend: HTML5Backend }, children);
7462
7577
  }
7463
7578
 
7464
- export { DDContext, DISCARD, Engine, Flow, Lib, binaryOnTree, binaryOnTreeBranch, broadCast, expandTree, forEachBranch, forEachItem, getBranch, getBranches, getItem, getPaths, getPositions, getReferences, getValue$1 as getValue, getVariable, graftTree, hasReference, interpolate, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, nAryOnTree, nAryOnTreeBranch, normalizePaths, normalizeVarDef, parseReference, primitives, pushItem, sameShape, simplifyTree$1 as simplifyTree, toArray, topSort, treeSize, treeStats, trimTree, uid$1 as uid, useDraggableNode, useFlow, useFunction, usePositions, useUpdatePositions, useVariable, variableStore };
7579
+ export { DDContext, DISCARD, Engine, Flow, Lib, binaryOnTree, binaryOnTreeBranch, broadCast, expandTree, forEachBranch, forEachItem, getBranch, getBranches, getItem, getPaths, getPositions, getReferences, getValue$1 as getValue, getVariable, graftTree, hasReference, interpolate, isEmptyTree, isReference, isSingleTon, isTree, mapTree, mapTreeBranch, nAryOnTree, nAryOnTreeBranch, normalizePaths, normalizeVarDef, parseReference, primitives, pushItem, sameShape, simplifyTree$1 as simplifyTree, toArray, topSort, treeSize, treeStats, trimTree, uid$1 as uid, useDraggableNode, useFlow, useFunction, usePositions, useUpdatePositions, useVariable, variableStore };
7465
7580
  //# sourceMappingURL=index.esm.js.map