@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.mjs CHANGED
@@ -390,6 +390,7 @@ var RequestType = /* @__PURE__ */ ((RequestType2) => {
390
390
  RequestType2["NodeReorder"] = "node_reorder";
391
391
  RequestType2["NodeMoveChildBefore"] = "node_move_child_before";
392
392
  RequestType2["NodeMoveChildAfter"] = "node_move_child_after";
393
+ RequestType2["NodeApplyChildOrder"] = "node_apply_child_order";
393
394
  RequestType2["PropertyGet"] = "property_get";
394
395
  RequestType2["PropertyUpdate"] = "property_update";
395
396
  RequestType2["RelationAdd"] = "relation_add";
@@ -409,6 +410,7 @@ var RequestType = /* @__PURE__ */ ((RequestType2) => {
409
410
  RequestType2["BranchUpdateHead"] = "branch_update_head";
410
411
  RequestType2["BranchMerge"] = "branch_merge";
411
412
  RequestType2["BranchCompare"] = "branch_compare";
413
+ RequestType2["BranchDiff"] = "branch_diff";
412
414
  RequestType2["TagCreate"] = "tag_create";
413
415
  RequestType2["TagGet"] = "tag_get";
414
416
  RequestType2["TagList"] = "tag_list";
@@ -429,6 +431,7 @@ var RequestType = /* @__PURE__ */ ((RequestType2) => {
429
431
  RequestType2["ArchetypeDelete"] = "archetype_delete";
430
432
  RequestType2["ArchetypePublish"] = "archetype_publish";
431
433
  RequestType2["ArchetypeUnpublish"] = "archetype_unpublish";
434
+ RequestType2["ArchetypeGetResolved"] = "archetype_get_resolved";
432
435
  RequestType2["ElementTypeCreate"] = "element_type_create";
433
436
  RequestType2["ElementTypeGet"] = "element_type_get";
434
437
  RequestType2["ElementTypeList"] = "element_type_list";
@@ -436,6 +439,7 @@ var RequestType = /* @__PURE__ */ ((RequestType2) => {
436
439
  RequestType2["ElementTypeDelete"] = "element_type_delete";
437
440
  RequestType2["ElementTypePublish"] = "element_type_publish";
438
441
  RequestType2["ElementTypeUnpublish"] = "element_type_unpublish";
442
+ RequestType2["ElementTypeGetResolved"] = "element_type_get_resolved";
439
443
  RequestType2["FullTextSearch"] = "full_text_search";
440
444
  RequestType2["VectorSearch"] = "vector_search";
441
445
  RequestType2["Subscribe"] = "subscribe";
@@ -904,6 +908,40 @@ var NodeOperations = class {
904
908
  const result = await this.sendRequest(payload);
905
909
  return result;
906
910
  }
911
+ /**
912
+ * Create a node, auto-creating any missing ancestor folders.
913
+ *
914
+ * @param options - Node creation options (with optional `parentNodeType`)
915
+ * @returns Created node
916
+ */
917
+ async createDeep(options) {
918
+ const payload = {
919
+ node_type: options.type,
920
+ path: options.path,
921
+ properties: options.properties ?? {},
922
+ content: options.content,
923
+ parent_node_type: options.parentNodeType
924
+ };
925
+ const result = await this.sendRequest(payload, "node_create_deep");
926
+ return result;
927
+ }
928
+ /**
929
+ * Upsert a node by path (create-or-update), auto-creating any missing ancestor folders.
930
+ *
931
+ * @param options - Node creation options (with optional `parentNodeType`)
932
+ * @returns Upserted node
933
+ */
934
+ async upsertDeep(options) {
935
+ const payload = {
936
+ node_type: options.type,
937
+ path: options.path,
938
+ properties: options.properties ?? {},
939
+ content: options.content,
940
+ parent_node_type: options.parentNodeType
941
+ };
942
+ const result = await this.sendRequest(payload, "node_upsert_deep");
943
+ return result;
944
+ }
907
945
  /**
908
946
  * Update an existing node
909
947
  *
@@ -953,6 +991,75 @@ var NodeOperations = class {
953
991
  throw error;
954
992
  }
955
993
  }
994
+ /**
995
+ * List a node's revision history (git-style "file history"), newest first.
996
+ *
997
+ * Each entry carries the `revision` (usable with `atRevision()` reads to
998
+ * fetch the full snapshot), plus when/who and whether the node was deleted
999
+ * at that revision. Always available regardless of the NodeType `auditable`
1000
+ * flag — it reflects the structural MVCC version history.
1001
+ *
1002
+ * @param id - Node ID
1003
+ * @param options - Optional `{ limit }` to cap the number of revisions
1004
+ * @returns Array of revision entries (newest first)
1005
+ *
1006
+ * @example
1007
+ * ```typescript
1008
+ * const history = await ws.nodes().history(nodeId, { limit: 50 });
1009
+ * for (const rev of history) {
1010
+ * const snapshot = await ws.atRevision(rev.revision).nodes().get(nodeId);
1011
+ * }
1012
+ * ```
1013
+ */
1014
+ async history(id, options) {
1015
+ const payload = {
1016
+ node_id: id,
1017
+ limit: options?.limit
1018
+ };
1019
+ const result = await this.sendRequest(payload, "node_history");
1020
+ return result ?? [];
1021
+ }
1022
+ /**
1023
+ * List a node's revision history by path (newest first).
1024
+ *
1025
+ * @param path - Node path
1026
+ * @param options - Optional `{ limit }` to cap the number of revisions
1027
+ * @returns Array of revision entries (newest first)
1028
+ */
1029
+ async historyByPath(path, options) {
1030
+ const payload = {
1031
+ path,
1032
+ limit: options?.limit
1033
+ };
1034
+ const result = await this.sendRequest(payload, "node_history");
1035
+ return result ?? [];
1036
+ }
1037
+ /**
1038
+ * Query a node's audit-log entries by ID.
1039
+ *
1040
+ * Audit logs are only produced for NodeTypes marked `auditable`. This is
1041
+ * distinct from {@link history}, which is the always-on structural revision
1042
+ * history available for every node.
1043
+ *
1044
+ * @param id - Node ID
1045
+ * @returns Array of audit-log entries
1046
+ */
1047
+ async auditLog(id) {
1048
+ const payload = { node_id: id };
1049
+ const result = await this.sendRequest(payload, "audit_query");
1050
+ return result ?? [];
1051
+ }
1052
+ /**
1053
+ * Query a node's audit-log entries by path.
1054
+ *
1055
+ * @param path - Node path
1056
+ * @returns Array of audit-log entries
1057
+ */
1058
+ async auditLogByPath(path) {
1059
+ const payload = { path };
1060
+ const result = await this.sendRequest(payload, "audit_query");
1061
+ return result ?? [];
1062
+ }
956
1063
  /**
957
1064
  * Query nodes
958
1065
  *
@@ -1120,7 +1227,7 @@ var NodeOperations = class {
1120
1227
  */
1121
1228
  async rename(nodePath, newName) {
1122
1229
  const payload = {
1123
- node_path: nodePath,
1230
+ old_path: nodePath,
1124
1231
  new_name: newName
1125
1232
  };
1126
1233
  const result = await this.sendRequest(payload, "node_rename");
@@ -1136,9 +1243,8 @@ var NodeOperations = class {
1136
1243
  */
1137
1244
  async copy(fromPath, toParentPath, newName) {
1138
1245
  const payload = {
1139
- from_path: fromPath,
1140
- to_parent_path: toParentPath,
1141
- deep: false
1246
+ source_path: fromPath,
1247
+ target_parent: toParentPath
1142
1248
  };
1143
1249
  if (newName !== void 0) {
1144
1250
  payload.new_name = newName;
@@ -1156,9 +1262,8 @@ var NodeOperations = class {
1156
1262
  */
1157
1263
  async copyTree(fromPath, toParentPath, newName) {
1158
1264
  const payload = {
1159
- from_path: fromPath,
1160
- to_parent_path: toParentPath,
1161
- deep: true
1265
+ source_path: fromPath,
1266
+ target_parent: toParentPath
1162
1267
  };
1163
1268
  if (newName !== void 0) {
1164
1269
  payload.new_name = newName;
@@ -1215,6 +1320,24 @@ var NodeOperations = class {
1215
1320
  const result = await this.sendRequest(payload, "node_move_child_after");
1216
1321
  return result;
1217
1322
  }
1323
+ /**
1324
+ * Replay a parent's child order from another branch onto the current branch.
1325
+ *
1326
+ * Carries node sibling-order across branches — useful for selective publish
1327
+ * flows, where copying node content (e.g. via SQL) does not move the ordering
1328
+ * index. Only children that exist under the parent on both branches are
1329
+ * reordered. The target branch is the connection's current branch.
1330
+ *
1331
+ * @param parentPath - Parent node path
1332
+ * @param sourceBranch - Branch to copy the child order FROM
1333
+ */
1334
+ async applyChildOrder(parentPath, sourceBranch) {
1335
+ const payload = {
1336
+ parent_path: parentPath,
1337
+ source_branch: sourceBranch
1338
+ };
1339
+ await this.sendRequest(payload, "node_apply_child_order");
1340
+ }
1218
1341
  // ========================================================================
1219
1342
  // Relationship Operations
1220
1343
  // ========================================================================
@@ -2300,6 +2423,17 @@ var Archetypes = class {
2300
2423
  "archetype_unpublish" /* ArchetypeUnpublish */
2301
2424
  );
2302
2425
  }
2426
+ /**
2427
+ * Get resolved Archetype with full inheritance applied
2428
+ */
2429
+ async getResolved(name) {
2430
+ return this.sendRequest(
2431
+ {
2432
+ name
2433
+ },
2434
+ "archetype_get_resolved" /* ArchetypeGetResolved */
2435
+ );
2436
+ }
2303
2437
  };
2304
2438
 
2305
2439
  // src/element-types.ts
@@ -2387,6 +2521,17 @@ var ElementTypes = class {
2387
2521
  "element_type_unpublish" /* ElementTypeUnpublish */
2388
2522
  );
2389
2523
  }
2524
+ /**
2525
+ * Get resolved ElementType with full inheritance applied
2526
+ */
2527
+ async getResolved(name) {
2528
+ return this.sendRequest(
2529
+ {
2530
+ name
2531
+ },
2532
+ "element_type_get_resolved" /* ElementTypeGetResolved */
2533
+ );
2534
+ }
2390
2535
  };
2391
2536
 
2392
2537
  // src/branches.ts
@@ -2488,6 +2633,21 @@ var Branches = class {
2488
2633
  "branch_compare" /* BranchCompare */
2489
2634
  );
2490
2635
  }
2636
+ /**
2637
+ * Per-node diff of `branch` relative to `baseBranch` (added/modified/deleted).
2638
+ *
2639
+ * Cheaper than reading both branch listings: cost scales with the number of
2640
+ * changed nodes since the branches diverged, not the total content.
2641
+ */
2642
+ async diff(branch, baseBranch) {
2643
+ return this.sendRequest(
2644
+ {
2645
+ branch,
2646
+ base_branch: baseBranch
2647
+ },
2648
+ "branch_diff" /* BranchDiff */
2649
+ );
2650
+ }
2491
2651
  };
2492
2652
 
2493
2653
  // src/tags.ts
@@ -5236,6 +5396,107 @@ var UploadManager = class {
5236
5396
  }
5237
5397
  };
5238
5398
 
5399
+ // src/http-schema.ts
5400
+ var HttpSchemaBase = class {
5401
+ constructor(repository, branch, client) {
5402
+ this.repository = repository;
5403
+ this.branch = branch;
5404
+ this.client = client;
5405
+ }
5406
+ /** Base management URL for this schema kind. */
5407
+ base() {
5408
+ return `/api/management/${this.repository}/${this.branch}/${this.kind}`;
5409
+ }
5410
+ /** List all schemas (or only published ones). */
5411
+ async list(publishedOnly = false) {
5412
+ const path = publishedOnly ? `${this.base()}/published` : this.base();
5413
+ const result = await this.client.managementRequest("GET", path);
5414
+ return Array.isArray(result) ? result : [];
5415
+ }
5416
+ /** Get a single schema by name. */
5417
+ async get(name) {
5418
+ return this.client.managementRequest("GET", `${this.base()}/${encodeURIComponent(name)}`);
5419
+ }
5420
+ /** Get the schema with full inheritance (`extends`) applied. */
5421
+ async getResolved(name) {
5422
+ return this.client.managementRequest(
5423
+ "GET",
5424
+ `${this.base()}/${encodeURIComponent(name)}/resolved`
5425
+ );
5426
+ }
5427
+ /** Create a schema. `name` is folded into the definition body if absent. */
5428
+ async create(name, definition, commit) {
5429
+ return this.client.managementRequest("POST", this.base(), {
5430
+ [this.defField]: { name, ...definition },
5431
+ commit
5432
+ });
5433
+ }
5434
+ /** Update an existing schema. */
5435
+ async update(name, definition, commit) {
5436
+ return this.client.managementRequest(
5437
+ "PUT",
5438
+ `${this.base()}/${encodeURIComponent(name)}`,
5439
+ { [this.defField]: { name, ...definition }, commit }
5440
+ );
5441
+ }
5442
+ /** Delete a schema. */
5443
+ async delete(name, commit) {
5444
+ return this.client.managementRequest(
5445
+ "DELETE",
5446
+ `${this.base()}/${encodeURIComponent(name)}`,
5447
+ commit
5448
+ );
5449
+ }
5450
+ /** Publish a schema. */
5451
+ async publish(name, commit) {
5452
+ return this.client.managementRequest(
5453
+ "POST",
5454
+ `${this.base()}/${encodeURIComponent(name)}/publish`,
5455
+ commit
5456
+ );
5457
+ }
5458
+ /** Unpublish a schema. */
5459
+ async unpublish(name, commit) {
5460
+ return this.client.managementRequest(
5461
+ "POST",
5462
+ `${this.base()}/${encodeURIComponent(name)}/unpublish`,
5463
+ commit
5464
+ );
5465
+ }
5466
+ };
5467
+ var HttpNodeTypes = class extends HttpSchemaBase {
5468
+ constructor() {
5469
+ super(...arguments);
5470
+ this.kind = "nodetypes";
5471
+ this.defField = "node_type";
5472
+ }
5473
+ /**
5474
+ * Get the resolved NodeType. Unlike archetypes/element types, NodeType
5475
+ * resolution can be workspace-aware (honors workspace NodeType pins).
5476
+ */
5477
+ async getResolved(name, opts) {
5478
+ const query = opts?.workspace ? `?workspace=${encodeURIComponent(opts.workspace)}` : "";
5479
+ return this.client.managementRequest(
5480
+ "GET",
5481
+ `${this.base()}/${encodeURIComponent(name)}/resolved${query}`
5482
+ );
5483
+ }
5484
+ };
5485
+ var HttpArchetypes = class extends HttpSchemaBase {
5486
+ constructor() {
5487
+ super(...arguments);
5488
+ this.kind = "archetypes";
5489
+ this.defField = "archetype";
5490
+ }
5491
+ };
5492
+ var HttpElementTypes = class extends HttpSchemaBase {
5493
+ constructor() {
5494
+ super(...arguments);
5495
+ this.kind = "elementtypes";
5496
+ this.defField = "element_type";
5497
+ }
5498
+ };
5499
+
5239
5500
  // src/http-client.ts
5240
5501
  var RaisinHttpClient = class extends EventEmitter {
5241
5502
  constructor(baseUrl, options = {}) {
@@ -5935,6 +6196,17 @@ var RaisinHttpClient = class extends EventEmitter {
5935
6196
  });
5936
6197
  return response.data;
5937
6198
  }
6199
+ /**
6200
+ * Make a management REST request and return the parsed body.
6201
+ *
6202
+ * @internal Used by the HTTP schema-management helpers
6203
+ * ({@link HttpNodeTypes}/{@link HttpArchetypes}/{@link HttpElementTypes}) to
6204
+ * reuse the client's centralized auth, timeout, and base-URL handling.
6205
+ */
6206
+ async managementRequest(method, path, body) {
6207
+ const response = await this.request({ method, path, body });
6208
+ return response.data;
6209
+ }
5938
6210
  /**
5939
6211
  * Get a simplified database interface for SSR
5940
6212
  * This returns an HTTP-based database client
@@ -6022,6 +6294,22 @@ var HttpDatabase = class _HttpDatabase {
6022
6294
  (repo, name, input) => this.client.invokeFunctionSync(repo, name, input)
6023
6295
  );
6024
6296
  }
6297
+ /** Effective branch for management calls. */
6298
+ schemaBranch() {
6299
+ return this.branch ?? this.client.getBranch();
6300
+ }
6301
+ /** NodeType management (get/list/getResolved/create/update/delete/publish/unpublish). */
6302
+ nodeTypes() {
6303
+ return new HttpNodeTypes(this.repository, this.schemaBranch(), this.client);
6304
+ }
6305
+ /** Archetype management (get/list/getResolved/create/update/delete/publish/unpublish). */
6306
+ archetypes() {
6307
+ return new HttpArchetypes(this.repository, this.schemaBranch(), this.client);
6308
+ }
6309
+ /** ElementType management (get/list/getResolved/create/update/delete/publish/unpublish). */
6310
+ elementTypes() {
6311
+ return new HttpElementTypes(this.repository, this.schemaBranch(), this.client);
6312
+ }
6025
6313
  };
6026
6314
  var HttpWorkspaceClient = class {
6027
6315
  constructor(repository, workspace, client) {
@@ -8280,8 +8568,11 @@ export {
8280
8568
  FlowClient,
8281
8569
  FlowsApi,
8282
8570
  FunctionsApi,
8571
+ HttpArchetypes,
8283
8572
  HttpDatabase,
8573
+ HttpElementTypes,
8284
8574
  HttpFunctionsApi,
8575
+ HttpNodeTypes,
8285
8576
  HttpWorkspaceClient,
8286
8577
  InboxApi,
8287
8578
  LocalStorageTokenStorage,