@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.mjs CHANGED
@@ -1162,17 +1162,40 @@ var NodeOperations = class {
1162
1162
  // Tree Operations
1163
1163
  // ========================================================================
1164
1164
  /**
1165
- * List children of a parent node
1165
+ * List children of a parent node, in editorial (drag-and-drop) order.
1166
1166
  *
1167
1167
  * @param parentPath - Path of the parent node
1168
1168
  * @returns Array of child nodes
1169
1169
  */
1170
1170
  async listChildren(parentPath) {
1171
+ const { items } = await this.listChildrenPage(parentPath);
1172
+ return items;
1173
+ }
1174
+ /**
1175
+ * List one page of a parent's children, in editorial order.
1176
+ *
1177
+ * Pagination is keyset-based: pass the previous response's `nextCursor` back as
1178
+ * `cursor` to get the following page. `nextCursor` is `null` on the last page.
1179
+ * Treat the cursor as opaque — do not parse or construct it.
1180
+ *
1181
+ * @param parentPath - Path of the parent node
1182
+ * @param options - `cursor` from a previous page, and page `limit`
1183
+ */
1184
+ async listChildrenPage(parentPath, options = {}) {
1171
1185
  const payload = {
1172
1186
  parent_path: parentPath
1173
1187
  };
1188
+ if (options.cursor !== void 0) payload.cursor = options.cursor;
1189
+ if (options.limit !== void 0) payload.limit = options.limit;
1174
1190
  const result = await this.sendRequest(payload, "node_list_children");
1175
- return result;
1191
+ if (Array.isArray(result)) {
1192
+ return { items: result, nextCursor: null };
1193
+ }
1194
+ const page = result;
1195
+ return {
1196
+ items: page.nodes ?? [],
1197
+ nextCursor: page.next_cursor == null ? null : JSON.stringify(page.next_cursor)
1198
+ };
1176
1199
  }
1177
1200
  /**
1178
1201
  * Get a node tree starting from a root node
@@ -1280,53 +1303,54 @@ var NodeOperations = class {
1280
1303
  return result;
1281
1304
  }
1282
1305
  /**
1283
- * Reorder a node by setting a new order key
1306
+ * Move a child to a specific position among its siblings.
1284
1307
  *
1285
- * @param nodePath - Node path
1286
- * @param orderKey - New order key (base62-encoded fractional index)
1287
- * @returns Reordered node
1308
+ * Positions are 0-based; a position past the end appends. The server owns the
1309
+ * fractional order key — you name a position, it mints the key.
1310
+ *
1311
+ * @param parentPath - Parent node path
1312
+ * @param childName - Name of the child to move (not a full path)
1313
+ * @param position - Target 0-based position among the parent's children
1314
+ * @returns The reordered node, carrying its newly assigned `order_key`
1288
1315
  */
1289
- async reorder(nodePath, orderKey) {
1316
+ async reorder(parentPath, childName, position) {
1290
1317
  const payload = {
1291
- node_path: nodePath,
1292
- order_key: orderKey
1318
+ parent_path: parentPath,
1319
+ child_name: childName,
1320
+ position
1293
1321
  };
1294
1322
  const result = await this.sendRequest(payload, "node_reorder");
1295
1323
  return result;
1296
1324
  }
1297
1325
  /**
1298
- * Move a child node before a reference sibling
1326
+ * Move a child so it sits immediately before one of its siblings.
1299
1327
  *
1300
1328
  * @param parentPath - Parent node path
1301
- * @param childPath - Child node path to move
1302
- * @param referencePath - Reference sibling path to position before
1303
- * @returns Moved node
1329
+ * @param childName - Name of the child to move (not a full path)
1330
+ * @param beforeChildName - Name of the sibling to sit before
1304
1331
  */
1305
- async moveChildBefore(parentPath, childPath, referencePath) {
1332
+ async moveChildBefore(parentPath, childName, beforeChildName) {
1306
1333
  const payload = {
1307
1334
  parent_path: parentPath,
1308
- child_path: childPath,
1309
- reference_path: referencePath
1335
+ child_name: childName,
1336
+ before_child_name: beforeChildName
1310
1337
  };
1311
- const result = await this.sendRequest(payload, "node_move_child_before");
1312
- return result;
1338
+ await this.sendRequest(payload, "node_move_child_before");
1313
1339
  }
1314
1340
  /**
1315
- * Move a child node after a reference sibling
1341
+ * Move a child so it sits immediately after one of its siblings.
1316
1342
  *
1317
1343
  * @param parentPath - Parent node path
1318
- * @param childPath - Child node path to move
1319
- * @param referencePath - Reference sibling path to position after
1320
- * @returns Moved node
1344
+ * @param childName - Name of the child to move (not a full path)
1345
+ * @param afterChildName - Name of the sibling to sit after
1321
1346
  */
1322
- async moveChildAfter(parentPath, childPath, referencePath) {
1347
+ async moveChildAfter(parentPath, childName, afterChildName) {
1323
1348
  const payload = {
1324
1349
  parent_path: parentPath,
1325
- child_path: childPath,
1326
- reference_path: referencePath
1350
+ child_name: childName,
1351
+ after_child_name: afterChildName
1327
1352
  };
1328
- const result = await this.sendRequest(payload, "node_move_child_after");
1329
- return result;
1353
+ await this.sendRequest(payload, "node_move_child_after");
1330
1354
  }
1331
1355
  /**
1332
1356
  * Replay a parent's child order from another branch onto the current branch.
@@ -8600,7 +8624,12 @@ var NodeBuilder = class _NodeBuilder {
8600
8624
  return this;
8601
8625
  }
8602
8626
  /**
8603
- * Set the order key
8627
+ * Set the order key.
8628
+ *
8629
+ * @deprecated The server owns editorial ordering: the order key is assigned by
8630
+ * the ordering index on write, so any value set here is overwritten. To place a
8631
+ * node, create it (it appends to the end of its parent) then call
8632
+ * `nodes.reorder()`, `nodes.moveChildBefore()` or `nodes.moveChildAfter()`.
8604
8633
  */
8605
8634
  orderKey(orderKey) {
8606
8635
  this.node.order_key = orderKey;
@@ -8680,10 +8709,10 @@ var NodeBuilder = class _NodeBuilder {
8680
8709
  if (!this.node.node_type) {
8681
8710
  throw new Error("Node type is required");
8682
8711
  }
8712
+ if (this.node.order_key === void 0) this.node.order_key = "";
8683
8713
  if (!this.node.children) this.node.children = [];
8684
8714
  if (!this.node.relations) this.node.relations = [];
8685
8715
  if (!this.node.properties) this.node.properties = {};
8686
- if (!this.node.order_key) this.node.order_key = "a";
8687
8716
  if (typeof this.node.version !== "number") this.node.version = 1;
8688
8717
  return this.node;
8689
8718
  }
@@ -8765,8 +8794,8 @@ var NodeHelpers = class {
8765
8794
  node_type: "MockType",
8766
8795
  properties: {},
8767
8796
  children: [],
8797
+ order_key: "",
8768
8798
  relations: [],
8769
- order_key: "a",
8770
8799
  version: 1,
8771
8800
  ...overrides
8772
8801
  };