@raisindb/client 0.1.18 → 0.1.38

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
@@ -47,8 +47,11 @@ __export(src_exports, {
47
47
  FlowClient: () => FlowClient,
48
48
  FlowsApi: () => FlowsApi,
49
49
  FunctionsApi: () => FunctionsApi,
50
+ HttpArchetypes: () => HttpArchetypes,
50
51
  HttpDatabase: () => HttpDatabase,
52
+ HttpElementTypes: () => HttpElementTypes,
51
53
  HttpFunctionsApi: () => HttpFunctionsApi,
54
+ HttpNodeTypes: () => HttpNodeTypes,
52
55
  HttpWorkspaceClient: () => HttpWorkspaceClient,
53
56
  InboxApi: () => InboxApi,
54
57
  LocalStorageTokenStorage: () => LocalStorageTokenStorage,
@@ -841,6 +844,7 @@ var RequestType = /* @__PURE__ */ ((RequestType2) => {
841
844
  RequestType2["NodeReorder"] = "node_reorder";
842
845
  RequestType2["NodeMoveChildBefore"] = "node_move_child_before";
843
846
  RequestType2["NodeMoveChildAfter"] = "node_move_child_after";
847
+ RequestType2["NodeApplyChildOrder"] = "node_apply_child_order";
844
848
  RequestType2["PropertyGet"] = "property_get";
845
849
  RequestType2["PropertyUpdate"] = "property_update";
846
850
  RequestType2["RelationAdd"] = "relation_add";
@@ -860,6 +864,7 @@ var RequestType = /* @__PURE__ */ ((RequestType2) => {
860
864
  RequestType2["BranchUpdateHead"] = "branch_update_head";
861
865
  RequestType2["BranchMerge"] = "branch_merge";
862
866
  RequestType2["BranchCompare"] = "branch_compare";
867
+ RequestType2["BranchDiff"] = "branch_diff";
863
868
  RequestType2["TagCreate"] = "tag_create";
864
869
  RequestType2["TagGet"] = "tag_get";
865
870
  RequestType2["TagList"] = "tag_list";
@@ -880,6 +885,7 @@ var RequestType = /* @__PURE__ */ ((RequestType2) => {
880
885
  RequestType2["ArchetypeDelete"] = "archetype_delete";
881
886
  RequestType2["ArchetypePublish"] = "archetype_publish";
882
887
  RequestType2["ArchetypeUnpublish"] = "archetype_unpublish";
888
+ RequestType2["ArchetypeGetResolved"] = "archetype_get_resolved";
883
889
  RequestType2["ElementTypeCreate"] = "element_type_create";
884
890
  RequestType2["ElementTypeGet"] = "element_type_get";
885
891
  RequestType2["ElementTypeList"] = "element_type_list";
@@ -887,6 +893,7 @@ var RequestType = /* @__PURE__ */ ((RequestType2) => {
887
893
  RequestType2["ElementTypeDelete"] = "element_type_delete";
888
894
  RequestType2["ElementTypePublish"] = "element_type_publish";
889
895
  RequestType2["ElementTypeUnpublish"] = "element_type_unpublish";
896
+ RequestType2["ElementTypeGetResolved"] = "element_type_get_resolved";
890
897
  RequestType2["FullTextSearch"] = "full_text_search";
891
898
  RequestType2["VectorSearch"] = "vector_search";
892
899
  RequestType2["Subscribe"] = "subscribe";
@@ -1355,6 +1362,40 @@ var NodeOperations = class {
1355
1362
  const result = await this.sendRequest(payload);
1356
1363
  return result;
1357
1364
  }
1365
+ /**
1366
+ * Create a node, auto-creating any missing ancestor folders.
1367
+ *
1368
+ * @param options - Node creation options (with optional `parentNodeType`)
1369
+ * @returns Created node
1370
+ */
1371
+ async createDeep(options) {
1372
+ const payload = {
1373
+ node_type: options.type,
1374
+ path: options.path,
1375
+ properties: options.properties ?? {},
1376
+ content: options.content,
1377
+ parent_node_type: options.parentNodeType
1378
+ };
1379
+ const result = await this.sendRequest(payload, "node_create_deep");
1380
+ return result;
1381
+ }
1382
+ /**
1383
+ * Upsert a node by path (create-or-update), auto-creating any missing ancestor folders.
1384
+ *
1385
+ * @param options - Node creation options (with optional `parentNodeType`)
1386
+ * @returns Upserted node
1387
+ */
1388
+ async upsertDeep(options) {
1389
+ const payload = {
1390
+ node_type: options.type,
1391
+ path: options.path,
1392
+ properties: options.properties ?? {},
1393
+ content: options.content,
1394
+ parent_node_type: options.parentNodeType
1395
+ };
1396
+ const result = await this.sendRequest(payload, "node_upsert_deep");
1397
+ return result;
1398
+ }
1358
1399
  /**
1359
1400
  * Update an existing node
1360
1401
  *
@@ -1404,6 +1445,75 @@ var NodeOperations = class {
1404
1445
  throw error;
1405
1446
  }
1406
1447
  }
1448
+ /**
1449
+ * List a node's revision history (git-style "file history"), newest first.
1450
+ *
1451
+ * Each entry carries the `revision` (usable with `atRevision()` reads to
1452
+ * fetch the full snapshot), plus when/who and whether the node was deleted
1453
+ * at that revision. Always available regardless of the NodeType `auditable`
1454
+ * flag — it reflects the structural MVCC version history.
1455
+ *
1456
+ * @param id - Node ID
1457
+ * @param options - Optional `{ limit }` to cap the number of revisions
1458
+ * @returns Array of revision entries (newest first)
1459
+ *
1460
+ * @example
1461
+ * ```typescript
1462
+ * const history = await ws.nodes().history(nodeId, { limit: 50 });
1463
+ * for (const rev of history) {
1464
+ * const snapshot = await ws.atRevision(rev.revision).nodes().get(nodeId);
1465
+ * }
1466
+ * ```
1467
+ */
1468
+ async history(id, options) {
1469
+ const payload = {
1470
+ node_id: id,
1471
+ limit: options?.limit
1472
+ };
1473
+ const result = await this.sendRequest(payload, "node_history");
1474
+ return result ?? [];
1475
+ }
1476
+ /**
1477
+ * List a node's revision history by path (newest first).
1478
+ *
1479
+ * @param path - Node path
1480
+ * @param options - Optional `{ limit }` to cap the number of revisions
1481
+ * @returns Array of revision entries (newest first)
1482
+ */
1483
+ async historyByPath(path, options) {
1484
+ const payload = {
1485
+ path,
1486
+ limit: options?.limit
1487
+ };
1488
+ const result = await this.sendRequest(payload, "node_history");
1489
+ return result ?? [];
1490
+ }
1491
+ /**
1492
+ * Query a node's audit-log entries by ID.
1493
+ *
1494
+ * Audit logs are only produced for NodeTypes marked `auditable`. This is
1495
+ * distinct from {@link history}, which is the always-on structural revision
1496
+ * history available for every node.
1497
+ *
1498
+ * @param id - Node ID
1499
+ * @returns Array of audit-log entries
1500
+ */
1501
+ async auditLog(id) {
1502
+ const payload = { node_id: id };
1503
+ const result = await this.sendRequest(payload, "audit_query");
1504
+ return result ?? [];
1505
+ }
1506
+ /**
1507
+ * Query a node's audit-log entries by path.
1508
+ *
1509
+ * @param path - Node path
1510
+ * @returns Array of audit-log entries
1511
+ */
1512
+ async auditLogByPath(path) {
1513
+ const payload = { path };
1514
+ const result = await this.sendRequest(payload, "audit_query");
1515
+ return result ?? [];
1516
+ }
1407
1517
  /**
1408
1518
  * Query nodes
1409
1519
  *
@@ -1571,7 +1681,7 @@ var NodeOperations = class {
1571
1681
  */
1572
1682
  async rename(nodePath, newName) {
1573
1683
  const payload = {
1574
- node_path: nodePath,
1684
+ old_path: nodePath,
1575
1685
  new_name: newName
1576
1686
  };
1577
1687
  const result = await this.sendRequest(payload, "node_rename");
@@ -1587,9 +1697,8 @@ var NodeOperations = class {
1587
1697
  */
1588
1698
  async copy(fromPath, toParentPath, newName) {
1589
1699
  const payload = {
1590
- from_path: fromPath,
1591
- to_parent_path: toParentPath,
1592
- deep: false
1700
+ source_path: fromPath,
1701
+ target_parent: toParentPath
1593
1702
  };
1594
1703
  if (newName !== void 0) {
1595
1704
  payload.new_name = newName;
@@ -1607,9 +1716,8 @@ var NodeOperations = class {
1607
1716
  */
1608
1717
  async copyTree(fromPath, toParentPath, newName) {
1609
1718
  const payload = {
1610
- from_path: fromPath,
1611
- to_parent_path: toParentPath,
1612
- deep: true
1719
+ source_path: fromPath,
1720
+ target_parent: toParentPath
1613
1721
  };
1614
1722
  if (newName !== void 0) {
1615
1723
  payload.new_name = newName;
@@ -1666,6 +1774,24 @@ var NodeOperations = class {
1666
1774
  const result = await this.sendRequest(payload, "node_move_child_after");
1667
1775
  return result;
1668
1776
  }
1777
+ /**
1778
+ * Replay a parent's child order from another branch onto the current branch.
1779
+ *
1780
+ * Carries node sibling-order across branches — useful for selective publish
1781
+ * flows, where copying node content (e.g. via SQL) does not move the ordering
1782
+ * index. Only children that exist under the parent on both branches are
1783
+ * reordered. The target branch is the connection's current branch.
1784
+ *
1785
+ * @param parentPath - Parent node path
1786
+ * @param sourceBranch - Branch to copy the child order FROM
1787
+ */
1788
+ async applyChildOrder(parentPath, sourceBranch) {
1789
+ const payload = {
1790
+ parent_path: parentPath,
1791
+ source_branch: sourceBranch
1792
+ };
1793
+ await this.sendRequest(payload, "node_apply_child_order");
1794
+ }
1669
1795
  // ========================================================================
1670
1796
  // Relationship Operations
1671
1797
  // ========================================================================
@@ -2751,6 +2877,17 @@ var Archetypes = class {
2751
2877
  "archetype_unpublish" /* ArchetypeUnpublish */
2752
2878
  );
2753
2879
  }
2880
+ /**
2881
+ * Get resolved Archetype with full inheritance applied
2882
+ */
2883
+ async getResolved(name) {
2884
+ return this.sendRequest(
2885
+ {
2886
+ name
2887
+ },
2888
+ "archetype_get_resolved" /* ArchetypeGetResolved */
2889
+ );
2890
+ }
2754
2891
  };
2755
2892
 
2756
2893
  // src/element-types.ts
@@ -2838,6 +2975,17 @@ var ElementTypes = class {
2838
2975
  "element_type_unpublish" /* ElementTypeUnpublish */
2839
2976
  );
2840
2977
  }
2978
+ /**
2979
+ * Get resolved ElementType with full inheritance applied
2980
+ */
2981
+ async getResolved(name) {
2982
+ return this.sendRequest(
2983
+ {
2984
+ name
2985
+ },
2986
+ "element_type_get_resolved" /* ElementTypeGetResolved */
2987
+ );
2988
+ }
2841
2989
  };
2842
2990
 
2843
2991
  // src/branches.ts
@@ -2939,6 +3087,21 @@ var Branches = class {
2939
3087
  "branch_compare" /* BranchCompare */
2940
3088
  );
2941
3089
  }
3090
+ /**
3091
+ * Per-node diff of `branch` relative to `baseBranch` (added/modified/deleted).
3092
+ *
3093
+ * Cheaper than reading both branch listings: cost scales with the number of
3094
+ * changed nodes since the branches diverged, not the total content.
3095
+ */
3096
+ async diff(branch, baseBranch) {
3097
+ return this.sendRequest(
3098
+ {
3099
+ branch,
3100
+ base_branch: baseBranch
3101
+ },
3102
+ "branch_diff" /* BranchDiff */
3103
+ );
3104
+ }
2942
3105
  };
2943
3106
 
2944
3107
  // src/tags.ts
@@ -6560,6 +6723,107 @@ var UploadManager = class {
6560
6723
  }
6561
6724
  };
6562
6725
 
6726
+ // src/http-schema.ts
6727
+ var HttpSchemaBase = class {
6728
+ constructor(repository, branch, client) {
6729
+ this.repository = repository;
6730
+ this.branch = branch;
6731
+ this.client = client;
6732
+ }
6733
+ /** Base management URL for this schema kind. */
6734
+ base() {
6735
+ return `/api/management/${this.repository}/${this.branch}/${this.kind}`;
6736
+ }
6737
+ /** List all schemas (or only published ones). */
6738
+ async list(publishedOnly = false) {
6739
+ const path = publishedOnly ? `${this.base()}/published` : this.base();
6740
+ const result = await this.client.managementRequest("GET", path);
6741
+ return Array.isArray(result) ? result : [];
6742
+ }
6743
+ /** Get a single schema by name. */
6744
+ async get(name) {
6745
+ return this.client.managementRequest("GET", `${this.base()}/${encodeURIComponent(name)}`);
6746
+ }
6747
+ /** Get the schema with full inheritance (`extends`) applied. */
6748
+ async getResolved(name) {
6749
+ return this.client.managementRequest(
6750
+ "GET",
6751
+ `${this.base()}/${encodeURIComponent(name)}/resolved`
6752
+ );
6753
+ }
6754
+ /** Create a schema. `name` is folded into the definition body if absent. */
6755
+ async create(name, definition, commit) {
6756
+ return this.client.managementRequest("POST", this.base(), {
6757
+ [this.defField]: { name, ...definition },
6758
+ commit
6759
+ });
6760
+ }
6761
+ /** Update an existing schema. */
6762
+ async update(name, definition, commit) {
6763
+ return this.client.managementRequest(
6764
+ "PUT",
6765
+ `${this.base()}/${encodeURIComponent(name)}`,
6766
+ { [this.defField]: { name, ...definition }, commit }
6767
+ );
6768
+ }
6769
+ /** Delete a schema. */
6770
+ async delete(name, commit) {
6771
+ return this.client.managementRequest(
6772
+ "DELETE",
6773
+ `${this.base()}/${encodeURIComponent(name)}`,
6774
+ commit
6775
+ );
6776
+ }
6777
+ /** Publish a schema. */
6778
+ async publish(name, commit) {
6779
+ return this.client.managementRequest(
6780
+ "POST",
6781
+ `${this.base()}/${encodeURIComponent(name)}/publish`,
6782
+ commit
6783
+ );
6784
+ }
6785
+ /** Unpublish a schema. */
6786
+ async unpublish(name, commit) {
6787
+ return this.client.managementRequest(
6788
+ "POST",
6789
+ `${this.base()}/${encodeURIComponent(name)}/unpublish`,
6790
+ commit
6791
+ );
6792
+ }
6793
+ };
6794
+ var HttpNodeTypes = class extends HttpSchemaBase {
6795
+ constructor() {
6796
+ super(...arguments);
6797
+ this.kind = "nodetypes";
6798
+ this.defField = "node_type";
6799
+ }
6800
+ /**
6801
+ * Get the resolved NodeType. Unlike archetypes/element types, NodeType
6802
+ * resolution can be workspace-aware (honors workspace NodeType pins).
6803
+ */
6804
+ async getResolved(name, opts) {
6805
+ const query = opts?.workspace ? `?workspace=${encodeURIComponent(opts.workspace)}` : "";
6806
+ return this.client.managementRequest(
6807
+ "GET",
6808
+ `${this.base()}/${encodeURIComponent(name)}/resolved${query}`
6809
+ );
6810
+ }
6811
+ };
6812
+ var HttpArchetypes = class extends HttpSchemaBase {
6813
+ constructor() {
6814
+ super(...arguments);
6815
+ this.kind = "archetypes";
6816
+ this.defField = "archetype";
6817
+ }
6818
+ };
6819
+ var HttpElementTypes = class extends HttpSchemaBase {
6820
+ constructor() {
6821
+ super(...arguments);
6822
+ this.kind = "elementtypes";
6823
+ this.defField = "element_type";
6824
+ }
6825
+ };
6826
+
6563
6827
  // src/http-client.ts
6564
6828
  var RaisinHttpClient = class extends import_events3.EventEmitter {
6565
6829
  constructor(baseUrl, options = {}) {
@@ -7259,6 +7523,17 @@ var RaisinHttpClient = class extends import_events3.EventEmitter {
7259
7523
  });
7260
7524
  return response.data;
7261
7525
  }
7526
+ /**
7527
+ * Make a management REST request and return the parsed body.
7528
+ *
7529
+ * @internal Used by the HTTP schema-management helpers
7530
+ * ({@link HttpNodeTypes}/{@link HttpArchetypes}/{@link HttpElementTypes}) to
7531
+ * reuse the client's centralized auth, timeout, and base-URL handling.
7532
+ */
7533
+ async managementRequest(method, path, body) {
7534
+ const response = await this.request({ method, path, body });
7535
+ return response.data;
7536
+ }
7262
7537
  /**
7263
7538
  * Get a simplified database interface for SSR
7264
7539
  * This returns an HTTP-based database client
@@ -7346,6 +7621,22 @@ var HttpDatabase = class _HttpDatabase {
7346
7621
  (repo, name, input) => this.client.invokeFunctionSync(repo, name, input)
7347
7622
  );
7348
7623
  }
7624
+ /** Effective branch for management calls. */
7625
+ schemaBranch() {
7626
+ return this.branch ?? this.client.getBranch();
7627
+ }
7628
+ /** NodeType management (get/list/getResolved/create/update/delete/publish/unpublish). */
7629
+ nodeTypes() {
7630
+ return new HttpNodeTypes(this.repository, this.schemaBranch(), this.client);
7631
+ }
7632
+ /** Archetype management (get/list/getResolved/create/update/delete/publish/unpublish). */
7633
+ archetypes() {
7634
+ return new HttpArchetypes(this.repository, this.schemaBranch(), this.client);
7635
+ }
7636
+ /** ElementType management (get/list/getResolved/create/update/delete/publish/unpublish). */
7637
+ elementTypes() {
7638
+ return new HttpElementTypes(this.repository, this.schemaBranch(), this.client);
7639
+ }
7349
7640
  };
7350
7641
  var HttpWorkspaceClient = class {
7351
7642
  constructor(repository, workspace, client) {
@@ -11629,8 +11920,11 @@ function createRaisinVue(vue) {
11629
11920
  FlowClient,
11630
11921
  FlowsApi,
11631
11922
  FunctionsApi,
11923
+ HttpArchetypes,
11632
11924
  HttpDatabase,
11925
+ HttpElementTypes,
11633
11926
  HttpFunctionsApi,
11927
+ HttpNodeTypes,
11634
11928
  HttpWorkspaceClient,
11635
11929
  InboxApi,
11636
11930
  LocalStorageTokenStorage,