@raisindb/client 0.5.1 → 0.5.2

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
@@ -1115,15 +1115,8 @@ var NodeOperations = class {
1115
1115
  * @returns Node or null if not found
1116
1116
  */
1117
1117
  async getByPath(path) {
1118
- try {
1119
- const result = await this.query({
1120
- query: { path },
1121
- limit: 1
1122
- });
1123
- return result.length > 0 ? result[0] : null;
1124
- } catch (error) {
1125
- return null;
1126
- }
1118
+ const result = await this.sendRequest({ path }, "node_query_by_path");
1119
+ return result ?? null;
1127
1120
  }
1128
1121
  /**
1129
1122
  * Query nodes by property
@@ -1134,14 +1127,12 @@ var NodeOperations = class {
1134
1127
  * @returns Array of nodes
1135
1128
  */
1136
1129
  async queryByProperty(propertyName, propertyValue, limit) {
1137
- return this.query({
1138
- query: {
1139
- properties: {
1140
- [propertyName]: propertyValue
1141
- }
1142
- },
1130
+ const payload = {
1131
+ query: { [propertyName]: propertyValue },
1143
1132
  limit
1144
- });
1133
+ };
1134
+ const result = await this.sendRequest(payload, "node_query_by_property");
1135
+ return result;
1145
1136
  }
1146
1137
  /**
1147
1138
  * Query nodes by type
@@ -1152,7 +1143,7 @@ var NodeOperations = class {
1152
1143
  */
1153
1144
  async queryByType(nodeType, limit) {
1154
1145
  return this.query({
1155
- query: { node_type: nodeType },
1146
+ query: { type: nodeType },
1156
1147
  limit
1157
1148
  });
1158
1149
  }
@@ -1231,7 +1222,7 @@ var NodeOperations = class {
1231
1222
  */
1232
1223
  async getTree(rootPath, maxDepth) {
1233
1224
  const payload = {
1234
- root_path: rootPath
1225
+ parent_path: rootPath
1235
1226
  };
1236
1227
  if (maxDepth !== void 0) {
1237
1228
  payload.max_depth = maxDepth;
@@ -1248,7 +1239,7 @@ var NodeOperations = class {
1248
1239
  */
1249
1240
  async getTreeFlat(rootPath, maxDepth) {
1250
1241
  const payload = {
1251
- root_path: rootPath
1242
+ parent_path: rootPath
1252
1243
  };
1253
1244
  if (maxDepth !== void 0) {
1254
1245
  payload.max_depth = maxDepth;
@@ -2288,7 +2279,8 @@ function createSqlHandler(sendRequest) {
2288
2279
 
2289
2280
  // src/node-types.ts
2290
2281
  var NodeTypes = class {
2291
- constructor(_context, sendRequest) {
2282
+ constructor(context, sendRequest) {
2283
+ this.context = context;
2292
2284
  this.sendRequest = sendRequest;
2293
2285
  }
2294
2286
  /**
@@ -2372,14 +2364,25 @@ var NodeTypes = class {
2372
2364
  );
2373
2365
  }
2374
2366
  /**
2375
- * Validate a node against its NodeType
2367
+ * Validate a node against its NodeType.
2368
+ *
2369
+ * The server validates in the context of a workspace (workspace-level
2370
+ * allow-lists and unique checks), so one is required. Pass it here, or
2371
+ * create the database with a workspace already in its context.
2376
2372
  */
2377
- async validate(node) {
2373
+ async validate(node, workspace) {
2374
+ const ws = workspace ?? this.context.workspace;
2375
+ if (!ws) {
2376
+ throw new Error(
2377
+ "nodeTypes().validate() requires a workspace: pass it as the second argument"
2378
+ );
2379
+ }
2378
2380
  return this.sendRequest(
2379
2381
  {
2380
2382
  node
2381
2383
  },
2382
- "node_type_validate" /* NodeTypeValidate */
2384
+ "node_type_validate" /* NodeTypeValidate */,
2385
+ { ...this.context, workspace: ws }
2383
2386
  );
2384
2387
  }
2385
2388
  /**
@@ -3825,7 +3828,7 @@ var ConversationManager = class {
3825
3828
  }
3826
3829
  async ensureFolderNode(workspace, path, title) {
3827
3830
  await this.sqlQuery(
3828
- `UPSERT INTO '${workspace}' (path, node_type, properties) VALUES ($1, 'raisin:Folder', $2::jsonb)`,
3831
+ `UPSERT INTO '${workspace}' (path, node_type, properties) VALUES ($1, 'raisin:AclFolder', $2::jsonb)`,
3829
3832
  [path, JSON.stringify({ title })]
3830
3833
  );
3831
3834
  }
@@ -5714,16 +5717,19 @@ var McpClient = class {
5714
5717
  /**
5715
5718
  * Subscribe to change notifications for a resource URI (or URI prefix).
5716
5719
  *
5717
- * Wraps the `resources/subscribe` JSON-RPC method, which upgrades to an SSE
5718
- * stream. The returned {@link McpResourceSubscription} is an async iterable of
5719
- * {@link McpResourceUpdate}; the server's initial subscription ack is consumed
5720
- * internally and not yielded. Call `close()` to end the stream.
5720
+ * Opens a `subscriptions/listen` stream (SSE) with a `resourceSubscriptions`
5721
+ * filter naming the URI. The returned {@link McpResourceSubscription} is an
5722
+ * async iterable of {@link McpResourceUpdate}; the server's acknowledgement
5723
+ * frame and the closing response are consumed internally and not yielded.
5724
+ * Call `close()` to end the stream.
5721
5725
  *
5722
5726
  * @param uri - `raisin://` URI (or prefix) to watch.
5723
5727
  * @returns A live, closeable subscription.
5724
5728
  */
5725
5729
  subscribeResource(uri) {
5726
- const stream = this.transport.subscribe("resources/subscribe", { uri });
5730
+ const stream = this.transport.subscribe("subscriptions/listen", {
5731
+ notifications: { resourceSubscriptions: [uri] }
5732
+ });
5727
5733
  return {
5728
5734
  close: () => stream.close(),
5729
5735
  async *[Symbol.asyncIterator]() {
@@ -6629,7 +6635,7 @@ var RaisinHttpClient = class extends EventEmitter {
6629
6635
  return frame?.result;
6630
6636
  }
6631
6637
  /**
6632
- * Open the `resources/subscribe` SSE stream for an MCP server endpoint.
6638
+ * Open the `subscriptions/listen` SSE stream for an MCP server endpoint.
6633
6639
  *
6634
6640
  * Streams JSON-RPC frames (the subscription ack followed by
6635
6641
  * `notifications/resources/updated` frames) from