@seed-hypermedia/client 0.0.82 → 0.0.83

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.
@@ -22,10 +22,9 @@ export declare function documentContainsLinkToChild(document: HMDocument, childI
22
22
  * Check if a document has a self-referential Query block
23
23
  * (a query to itself that would automatically include children).
24
24
  *
25
- * A query block is self-referential when one of its `query.includes` entries
26
- * has `space === documentId.uid` AND a path that, after normalization, equals
27
- * the document's path. Empty `space` or `path` does not count as self — that
28
- * represents an unconfigured query block, which the editor renders empty.
25
+ * A query block is self-referential when its target is implicit/empty or one
26
+ * of its `query.includes` entries targets the document. New Collections use
27
+ * the implicit empty target until it is resolved against their published ID.
29
28
  */
30
29
  export declare function documentHasSelfQuery(document: HMDocument, documentId: UnpackedHypermediaId): boolean;
31
30
  /**
@@ -4,13 +4,13 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-55OXHA27.mjs";
7
+ } from "./chunk-SIYJHDMJ.mjs";
8
8
  import "./chunk-JT57MV7Y.mjs";
9
9
  import "./chunk-PJ2RFT5A.mjs";
10
- import "./chunk-C42YWLL2.mjs";
10
+ import "./chunk-CRMBYTZY.mjs";
11
11
  import "./chunk-LVAHHQIK.mjs";
12
12
  import "./chunk-DR3HJ6BV.mjs";
13
- import "./chunk-MZUGCZJ6.mjs";
13
+ import "./chunk-KMQYEO46.mjs";
14
14
  import "./chunk-7P6ASYW6.mjs";
15
15
  export {
16
16
  autoLinkChildToParent,
@@ -7,8 +7,8 @@ import {
7
7
  emitFrontmatter,
8
8
  parseDraftFilename,
9
9
  slugify
10
- } from "./chunk-TET43O3D.mjs";
11
- import "./chunk-MZUGCZJ6.mjs";
10
+ } from "./chunk-E6YSFT63.mjs";
11
+ import "./chunk-KMQYEO46.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
14
14
  blocksToMarkdown,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createCapability,
3
3
  resolveCapability
4
- } from "./chunk-BO2QSSIU.mjs";
4
+ } from "./chunk-V2UNLCDS.mjs";
5
5
  import "./chunk-LVAHHQIK.mjs";
6
6
  import "./chunk-NBCHK76Q.mjs";
7
7
  import "./chunk-DR3HJ6BV.mjs";
8
- import "./chunk-MZUGCZJ6.mjs";
8
+ import "./chunk-KMQYEO46.mjs";
9
9
  import "./chunk-3TPCJCVO.mjs";
10
10
  import "./chunk-7P6ASYW6.mjs";
11
11
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  codePointLength
3
- } from "./chunk-MZUGCZJ6.mjs";
3
+ } from "./chunk-KMQYEO46.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
@@ -2,7 +2,7 @@ import {
2
2
  entityQueryPathToHmIdPath,
3
3
  parseFragment,
4
4
  unpackHmId
5
- } from "./chunk-MZUGCZJ6.mjs";
5
+ } from "./chunk-KMQYEO46.mjs";
6
6
 
7
7
  // src/hm-resolver.ts
8
8
  async function resolveHypermediaUrl(url, opts) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  packHmId,
3
3
  unpackHmId
4
- } from "./chunk-MZUGCZJ6.mjs";
4
+ } from "./chunk-KMQYEO46.mjs";
5
5
 
6
6
  // src/document-state.ts
7
7
  async function resolveDocumentState(client, targetId) {
@@ -6,7 +6,7 @@ import {
6
6
  HMBlockSchema,
7
7
  codePointLength,
8
8
  toNumber
9
- } from "./chunk-MZUGCZJ6.mjs";
9
+ } from "./chunk-KMQYEO46.mjs";
10
10
 
11
11
  // src/editorblock-to-hmblock.ts
12
12
  function toHMBlockType(editorBlockType) {
@@ -1,6 +1,7 @@
1
1
  import {
2
+ normalizeQuerySort,
2
3
  unpackHmId
3
- } from "./chunk-MZUGCZJ6.mjs";
4
+ } from "./chunk-KMQYEO46.mjs";
4
5
 
5
6
  // src/blocks-to-markdown.ts
6
7
  import { stringify as stringifyYaml } from "yaml";
@@ -589,7 +590,7 @@ async function resolveBlockEmbed(block, depth, ctx) {
589
590
  }
590
591
  }
591
592
  async function resolveQuery(block, depth, ctx) {
592
- var _a, _b;
593
+ var _a;
593
594
  const ind = resolvedIndent(depth);
594
595
  try {
595
596
  const attrs = block.attributes;
@@ -603,7 +604,7 @@ async function resolveQuery(block, depth, ctx) {
603
604
  path: inc.path,
604
605
  mode: inc.mode || "Children"
605
606
  }));
606
- sort = (_a = queryConfig.sort) == null ? void 0 : _a.map((s) => ({ term: s.term, reverse: s.reverse ?? false }));
607
+ sort = normalizeQuerySort(queryConfig.sort);
607
608
  limit = queryConfig.limit;
608
609
  } else {
609
610
  const space = (attrs == null ? void 0 : attrs.space) || "";
@@ -619,13 +620,13 @@ async function resolveQuery(block, depth, ctx) {
619
620
  }
620
621
  const results = await ctx.client.request("Query", {
621
622
  includes,
622
- sort: sort || [{ term: "UpdateTime", reverse: true }],
623
+ sort: (sort == null ? void 0 : sort.length) ? sort : [{ term: "updated", reverse: true }],
623
624
  limit: limit || 10
624
625
  });
625
- if (!((_b = results == null ? void 0 : results.results) == null ? void 0 : _b.length)) return ind + "<!-- Query: no results -->";
626
+ if (!((_a = results == null ? void 0 : results.results) == null ? void 0 : _a.length)) return ind + "<!-- Query: no results -->";
626
627
  return results.results.map((doc) => {
627
- var _a2, _b2;
628
- const name = ((_a2 = doc.metadata) == null ? void 0 : _a2.name) || ((_b2 = doc.id.path) == null ? void 0 : _b2.join("/")) || doc.id.uid;
628
+ var _a2, _b;
629
+ const name = ((_a2 = doc.metadata) == null ? void 0 : _a2.name) || ((_b = doc.id.path) == null ? void 0 : _b.join("/")) || doc.id.uid;
629
630
  return ind + `- [${name}](${doc.id.id})`;
630
631
  }).join("\n");
631
632
  } catch (error) {
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  hmIdPathToEntityQueryPath,
11
11
  packHmId
12
- } from "./chunk-MZUGCZJ6.mjs";
12
+ } from "./chunk-KMQYEO46.mjs";
13
13
 
14
14
  // src/comment.ts
15
15
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -36,6 +36,9 @@ var HMQueryTableColumnSchema = z.object({
36
36
  });
37
37
  var HMQueryTableConfigSchema = z.object({
38
38
  columns: z.array(HMQueryTableColumnSchema),
39
+ // Legacy `sorting` field from the pre-unification table config. Sort now lives
40
+ // in the query's `sort` field; this is tolerated (and ignored) so old
41
+ // persisted documents still validate without crashing.
39
42
  sorting: z.array(z.object({ id: z.string(), desc: z.boolean() })).optional()
40
43
  });
41
44
  var baseAnnotationProperties = {
@@ -474,17 +477,33 @@ var HMQueryInclusionSchema = z.object({
474
477
  path: z.string().optional(),
475
478
  mode: z.union([z.literal("Children"), z.literal("AllDescendants")])
476
479
  });
480
+ var legacySortTermMap = {
481
+ Title: "title",
482
+ Path: "path",
483
+ CreateTime: "created",
484
+ UpdateTime: "updated",
485
+ DisplayTime: "displayTime",
486
+ ActivityTime: "activity"
487
+ };
488
+ var legacyTimeSortTerms = /* @__PURE__ */ new Set(["CreateTime", "UpdateTime", "DisplayTime", "ActivityTime"]);
489
+ function normalizeQuerySortEntry(entry) {
490
+ const rawTerm = entry.term ?? "updated";
491
+ let reverse = entry.reverse ?? false;
492
+ const mapped = legacySortTermMap[rawTerm];
493
+ if (mapped !== void 0) {
494
+ if (legacyTimeSortTerms.has(rawTerm)) reverse = !reverse;
495
+ return { term: mapped, reverse };
496
+ }
497
+ return { term: rawTerm, reverse };
498
+ }
499
+ function normalizeQuerySort(sort) {
500
+ if (!Array.isArray(sort)) return [];
501
+ return sort.map(normalizeQuerySortEntry);
502
+ }
477
503
  var HMQuerySortSchema = z.object({
478
- reverse: z.boolean().default(false),
479
- term: z.union([
480
- z.literal("Path"),
481
- z.literal("Title"),
482
- z.literal("CreateTime"),
483
- z.literal("UpdateTime"),
484
- z.literal("DisplayTime"),
485
- z.literal("ActivityTime")
486
- ])
487
- });
504
+ term: z.string().optional(),
505
+ reverse: z.boolean().optional()
506
+ }).transform(normalizeQuerySortEntry);
488
507
  var HMQuerySchema = z.object({
489
508
  includes: z.array(HMQueryInclusionSchema),
490
509
  sort: z.array(HMQuerySortSchema).optional(),
@@ -757,7 +776,13 @@ var HMDraftContentSchema = z.object({
757
776
  * Snapshot of the published HMBlockNode[] tree at the time the draft was
758
777
  * started (or last rebased). Acts as the merge base for three-way diff.
759
778
  */
760
- baseBlocks: z.array(z.any()).optional()
779
+ baseBlocks: z.array(z.any()).optional(),
780
+ /**
781
+ * Optional path the user picked for this not-yet-published draft via the
782
+ * rename affordance in the publish popover. Persisted so it survives reloads
783
+ * and is honored at publish time instead of the title-derived slug.
784
+ */
785
+ publishPath: z.array(z.string()).optional()
761
786
  });
762
787
  var HMDraftMetaBaseSchema = z.object({
763
788
  id: z.string(),
@@ -1487,6 +1512,8 @@ export {
1487
1512
  HMSiteMemberSchema,
1488
1513
  HMAccountsMetadataSchema,
1489
1514
  HMQueryInclusionSchema,
1515
+ normalizeQuerySortEntry,
1516
+ normalizeQuerySort,
1490
1517
  HMQuerySortSchema,
1491
1518
  HMQuerySchema,
1492
1519
  HMBlockTableSchema,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-MZENVC36.mjs";
3
+ } from "./chunk-2GOQZ3DV.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-52P3E6H6.mjs";
@@ -15,7 +15,7 @@ import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-MZUGCZJ6.mjs";
18
+ } from "./chunk-KMQYEO46.mjs";
19
19
 
20
20
  // src/client.ts
21
21
  import { encode as cborEncode } from "@ipld/dag-cbor";
@@ -7,12 +7,12 @@ import {
7
7
  } from "./chunk-PJ2RFT5A.mjs";
8
8
  import {
9
9
  resolveDocumentState
10
- } from "./chunk-C42YWLL2.mjs";
10
+ } from "./chunk-CRMBYTZY.mjs";
11
11
  import {
12
12
  entityQueryPathToHmIdPath,
13
13
  packHmId,
14
14
  unpackHmId
15
- } from "./chunk-MZUGCZJ6.mjs";
15
+ } from "./chunk-KMQYEO46.mjs";
16
16
 
17
17
  // src/auto-link.ts
18
18
  import { CID } from "multiformats/cid";
@@ -49,6 +49,7 @@ function documentHasSelfQuery(document, documentId) {
49
49
  const parentPathStr = (documentId.path || []).join("/");
50
50
  function isSelfMatch(include) {
51
51
  if (!include) return false;
52
+ if (!include.space && !include.path) return true;
52
53
  if (include.space !== documentId.uid) return false;
53
54
  const includePath = entityQueryPathToHmIdPath(include.path);
54
55
  return (includePath || []).join("/") === parentPathStr;
@@ -58,6 +59,7 @@ function documentHasSelfQuery(document, documentId) {
58
59
  for (const node of nodes) {
59
60
  if (node.block.type === "Query") {
60
61
  const includes = (_b = (_a = node.block.attributes) == null ? void 0 : _a.query) == null ? void 0 : _b.includes;
62
+ if (!includes || includes.length === 0) return true;
61
63
  if (includes == null ? void 0 : includes.some(isSelfMatch)) return true;
62
64
  }
63
65
  if (node.children && searchBlocks(node.children)) return true;
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  resolveId
3
- } from "./chunk-D2LTD2KZ.mjs";
3
+ } from "./chunk-4VD46ULS.mjs";
4
4
  import {
5
5
  createSeedClient
6
- } from "./chunk-RCVLNXG6.mjs";
6
+ } from "./chunk-QBYF2PVS.mjs";
7
7
  import {
8
8
  unpackHmId
9
- } from "./chunk-MZUGCZJ6.mjs";
9
+ } from "./chunk-KMQYEO46.mjs";
10
10
 
11
11
  // src/resource-read.ts
12
12
  async function resolveIdWithClient(rawId, options = {}) {
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packBaseId
10
- } from "./chunk-MZUGCZJ6.mjs";
10
+ } from "./chunk-KMQYEO46.mjs";
11
11
 
12
12
  // src/capability.ts
13
13
  import { base58btc } from "multiformats/bases/base58";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSurrogate
3
- } from "./chunk-MZUGCZJ6.mjs";
3
+ } from "./chunk-KMQYEO46.mjs";
4
4
 
5
5
  // src/hmblock-to-editorblock.ts
6
6
  function toEditorBlockType(hmBlockType) {
package/dist/client.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createSeedClient,
3
3
  deserializeQueryString
4
- } from "./chunk-RCVLNXG6.mjs";
4
+ } from "./chunk-QBYF2PVS.mjs";
5
5
  import "./chunk-CBELM7KX.mjs";
6
6
  import "./chunk-JT57MV7Y.mjs";
7
7
  import "./chunk-PJ2RFT5A.mjs";
8
8
  import "./chunk-LVAHHQIK.mjs";
9
9
  import "./chunk-DR3HJ6BV.mjs";
10
- import "./chunk-MZUGCZJ6.mjs";
10
+ import "./chunk-KMQYEO46.mjs";
11
11
  import "./chunk-7P6ASYW6.mjs";
12
12
  export {
13
13
  createSeedClient,
package/dist/comment.mjs CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  deleteComment,
5
5
  trimTrailingEmptyBlocks,
6
6
  updateComment
7
- } from "./chunk-IREIRKVP.mjs";
7
+ } from "./chunk-IOXGTLKJ.mjs";
8
8
  import "./chunk-N3P7S5YZ.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
11
- import "./chunk-MZUGCZJ6.mjs";
11
+ import "./chunk-KMQYEO46.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
14
14
  commentRecordIdFromBlob,
@@ -4,8 +4,8 @@ import {
4
4
  followToDocument,
5
5
  resolveDocumentState,
6
6
  resolveEditableDocument
7
- } from "./chunk-C42YWLL2.mjs";
8
- import "./chunk-MZUGCZJ6.mjs";
7
+ } from "./chunk-CRMBYTZY.mjs";
8
+ import "./chunk-KMQYEO46.mjs";
9
9
  import "./chunk-7P6ASYW6.mjs";
10
10
  export {
11
11
  describeRedirect,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  editorBlockToHMBlock,
3
3
  editorBlocksToHMBlockNodes
4
- } from "./chunk-2OMSCQ56.mjs";
4
+ } from "./chunk-E4PGX55A.mjs";
5
5
  import "./chunk-N3P7S5YZ.mjs";
6
- import "./chunk-MZUGCZJ6.mjs";
6
+ import "./chunk-KMQYEO46.mjs";
7
7
  import "./chunk-7P6ASYW6.mjs";
8
8
  export {
9
9
  editorBlockToHMBlock,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  resolveHypermediaUrl,
3
3
  resolveId
4
- } from "./chunk-D2LTD2KZ.mjs";
5
- import "./chunk-MZUGCZJ6.mjs";
4
+ } from "./chunk-4VD46ULS.mjs";
5
+ import "./chunk-KMQYEO46.mjs";
6
6
  import "./chunk-7P6ASYW6.mjs";
7
7
  export {
8
8
  resolveHypermediaUrl,