@raisindb/client 0.2.5 → 0.3.0

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.js CHANGED
@@ -1622,17 +1622,40 @@ var NodeOperations = class {
1622
1622
  // Tree Operations
1623
1623
  // ========================================================================
1624
1624
  /**
1625
- * List children of a parent node
1625
+ * List children of a parent node, in editorial (drag-and-drop) order.
1626
1626
  *
1627
1627
  * @param parentPath - Path of the parent node
1628
1628
  * @returns Array of child nodes
1629
1629
  */
1630
1630
  async listChildren(parentPath) {
1631
+ const { items } = await this.listChildrenPage(parentPath);
1632
+ return items;
1633
+ }
1634
+ /**
1635
+ * List one page of a parent's children, in editorial order.
1636
+ *
1637
+ * Pagination is keyset-based: pass the previous response's `nextCursor` back as
1638
+ * `cursor` to get the following page. `nextCursor` is `null` on the last page.
1639
+ * Treat the cursor as opaque — do not parse or construct it.
1640
+ *
1641
+ * @param parentPath - Path of the parent node
1642
+ * @param options - `cursor` from a previous page, and page `limit`
1643
+ */
1644
+ async listChildrenPage(parentPath, options = {}) {
1631
1645
  const payload = {
1632
1646
  parent_path: parentPath
1633
1647
  };
1648
+ if (options.cursor !== void 0) payload.cursor = options.cursor;
1649
+ if (options.limit !== void 0) payload.limit = options.limit;
1634
1650
  const result = await this.sendRequest(payload, "node_list_children");
1635
- return result;
1651
+ if (Array.isArray(result)) {
1652
+ return { items: result, nextCursor: null };
1653
+ }
1654
+ const page = result;
1655
+ return {
1656
+ items: page.nodes ?? [],
1657
+ nextCursor: page.next_cursor == null ? null : JSON.stringify(page.next_cursor)
1658
+ };
1636
1659
  }
1637
1660
  /**
1638
1661
  * Get a node tree starting from a root node
@@ -1740,53 +1763,54 @@ var NodeOperations = class {
1740
1763
  return result;
1741
1764
  }
1742
1765
  /**
1743
- * Reorder a node by setting a new order key
1766
+ * Move a child to a specific position among its siblings.
1744
1767
  *
1745
- * @param nodePath - Node path
1746
- * @param orderKey - New order key (base62-encoded fractional index)
1747
- * @returns Reordered node
1768
+ * Positions are 0-based; a position past the end appends. The server owns the
1769
+ * fractional order key — you name a position, it mints the key.
1770
+ *
1771
+ * @param parentPath - Parent node path
1772
+ * @param childName - Name of the child to move (not a full path)
1773
+ * @param position - Target 0-based position among the parent's children
1774
+ * @returns The reordered node, carrying its newly assigned `order_key`
1748
1775
  */
1749
- async reorder(nodePath, orderKey) {
1776
+ async reorder(parentPath, childName, position) {
1750
1777
  const payload = {
1751
- node_path: nodePath,
1752
- order_key: orderKey
1778
+ parent_path: parentPath,
1779
+ child_name: childName,
1780
+ position
1753
1781
  };
1754
1782
  const result = await this.sendRequest(payload, "node_reorder");
1755
1783
  return result;
1756
1784
  }
1757
1785
  /**
1758
- * Move a child node before a reference sibling
1786
+ * Move a child so it sits immediately before one of its siblings.
1759
1787
  *
1760
1788
  * @param parentPath - Parent node path
1761
- * @param childPath - Child node path to move
1762
- * @param referencePath - Reference sibling path to position before
1763
- * @returns Moved node
1789
+ * @param childName - Name of the child to move (not a full path)
1790
+ * @param beforeChildName - Name of the sibling to sit before
1764
1791
  */
1765
- async moveChildBefore(parentPath, childPath, referencePath) {
1792
+ async moveChildBefore(parentPath, childName, beforeChildName) {
1766
1793
  const payload = {
1767
1794
  parent_path: parentPath,
1768
- child_path: childPath,
1769
- reference_path: referencePath
1795
+ child_name: childName,
1796
+ before_child_name: beforeChildName
1770
1797
  };
1771
- const result = await this.sendRequest(payload, "node_move_child_before");
1772
- return result;
1798
+ await this.sendRequest(payload, "node_move_child_before");
1773
1799
  }
1774
1800
  /**
1775
- * Move a child node after a reference sibling
1801
+ * Move a child so it sits immediately after one of its siblings.
1776
1802
  *
1777
1803
  * @param parentPath - Parent node path
1778
- * @param childPath - Child node path to move
1779
- * @param referencePath - Reference sibling path to position after
1780
- * @returns Moved node
1804
+ * @param childName - Name of the child to move (not a full path)
1805
+ * @param afterChildName - Name of the sibling to sit after
1781
1806
  */
1782
- async moveChildAfter(parentPath, childPath, referencePath) {
1807
+ async moveChildAfter(parentPath, childName, afterChildName) {
1783
1808
  const payload = {
1784
1809
  parent_path: parentPath,
1785
- child_path: childPath,
1786
- reference_path: referencePath
1810
+ child_name: childName,
1811
+ after_child_name: afterChildName
1787
1812
  };
1788
- const result = await this.sendRequest(payload, "node_move_child_after");
1789
- return result;
1813
+ await this.sendRequest(payload, "node_move_child_after");
1790
1814
  }
1791
1815
  /**
1792
1816
  * Replay a parent's child order from another branch onto the current branch.
@@ -9933,7 +9957,12 @@ var NodeBuilder = class _NodeBuilder {
9933
9957
  return this;
9934
9958
  }
9935
9959
  /**
9936
- * Set the order key
9960
+ * Set the order key.
9961
+ *
9962
+ * @deprecated The server owns editorial ordering: the order key is assigned by
9963
+ * the ordering index on write, so any value set here is overwritten. To place a
9964
+ * node, create it (it appends to the end of its parent) then call
9965
+ * `nodes.reorder()`, `nodes.moveChildBefore()` or `nodes.moveChildAfter()`.
9937
9966
  */
9938
9967
  orderKey(orderKey) {
9939
9968
  this.node.order_key = orderKey;
@@ -10013,10 +10042,10 @@ var NodeBuilder = class _NodeBuilder {
10013
10042
  if (!this.node.node_type) {
10014
10043
  throw new Error("Node type is required");
10015
10044
  }
10045
+ if (this.node.order_key === void 0) this.node.order_key = "";
10016
10046
  if (!this.node.children) this.node.children = [];
10017
10047
  if (!this.node.relations) this.node.relations = [];
10018
10048
  if (!this.node.properties) this.node.properties = {};
10019
- if (!this.node.order_key) this.node.order_key = "a";
10020
10049
  if (typeof this.node.version !== "number") this.node.version = 1;
10021
10050
  return this.node;
10022
10051
  }
@@ -10098,8 +10127,8 @@ var NodeHelpers = class {
10098
10127
  node_type: "MockType",
10099
10128
  properties: {},
10100
10129
  children: [],
10130
+ order_key: "",
10101
10131
  relations: [],
10102
- order_key: "a",
10103
10132
  version: 1,
10104
10133
  ...overrides
10105
10134
  };