@seed-hypermedia/client 0.0.27 → 0.0.28

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.
@@ -20,6 +20,11 @@ export declare function documentContainsLinkToChild(document: HMDocument, childI
20
20
  /**
21
21
  * Check if a document has a self-referential Query block
22
22
  * (a query to itself that would automatically include children).
23
+ *
24
+ * A query block is self-referential when one of its `query.includes` entries
25
+ * has `space === documentId.uid` AND a path that, after normalization, equals
26
+ * the document's path. Empty `space` or `path` does not count as self — that
27
+ * represents an unconfigured query block, which the editor renders empty.
23
28
  */
24
29
  export declare function documentHasSelfQuery(document: HMDocument, documentId: UnpackedHypermediaId): boolean;
25
30
  /**
package/dist/index.mjs CHANGED
@@ -3279,21 +3279,19 @@ function documentContainsLinkToChild(document, childId) {
3279
3279
  return searchBlocks(document.content || []);
3280
3280
  }
3281
3281
  function documentHasSelfQuery(document, documentId) {
3282
- var _a;
3283
- const documentPathWithSlash = hmIdPathToEntityQueryPath(documentId.path);
3284
- const documentPathWithoutSlash = ((_a = documentId.path) == null ? void 0 : _a.join("/")) || "";
3282
+ const parentPathStr = (documentId.path || []).join("/");
3283
+ function isSelfMatch(include) {
3284
+ if (!include) return false;
3285
+ if (include.space !== documentId.uid) return false;
3286
+ const includePath = entityQueryPathToHmIdPath(include.path);
3287
+ return (includePath || []).join("/") === parentPathStr;
3288
+ }
3285
3289
  function searchBlocks(nodes) {
3286
- var _a2;
3290
+ var _a, _b;
3287
3291
  for (const node of nodes) {
3288
3292
  if (node.block.type === "Query") {
3289
- const query = (_a2 = node.block.attributes) == null ? void 0 : _a2.query;
3290
- if (query == null ? void 0 : query.includes) {
3291
- for (const inc of query.includes) {
3292
- const isSpaceMatch = !inc.space || inc.space === documentId.uid;
3293
- const isPathMatch = !inc.path || inc.path === documentPathWithSlash || inc.path === documentPathWithoutSlash;
3294
- if (isSpaceMatch && isPathMatch) return true;
3295
- }
3296
- }
3293
+ const includes = (_b = (_a = node.block.attributes) == null ? void 0 : _a.query) == null ? void 0 : _b.includes;
3294
+ if (includes == null ? void 0 : includes.some(isSelfMatch)) return true;
3297
3295
  }
3298
3296
  if (node.children && searchBlocks(node.children)) return true;
3299
3297
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-hypermedia/client",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/seed-hypermedia/seed",