@seed-hypermedia/client 0.0.88 → 0.0.90

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.
@@ -4,13 +4,13 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-J45O2Y7E.mjs";
7
+ } from "./chunk-HNQDRHGQ.mjs";
8
8
  import "./chunk-O5MHN2EO.mjs";
9
9
  import "./chunk-PJ2RFT5A.mjs";
10
- import "./chunk-STKAE4YB.mjs";
10
+ import "./chunk-UTZ42CJC.mjs";
11
11
  import "./chunk-LVAHHQIK.mjs";
12
12
  import "./chunk-DR3HJ6BV.mjs";
13
- import "./chunk-GIO2JLKT.mjs";
13
+ import "./chunk-VNZHLLJE.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-GVFAXUKA.mjs";
11
- import "./chunk-GIO2JLKT.mjs";
10
+ } from "./chunk-UFLGAJWJ.mjs";
11
+ import "./chunk-VNZHLLJE.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-I273FRIR.mjs";
4
+ } from "./chunk-RRXP7SCF.mjs";
5
5
  import "./chunk-LVAHHQIK.mjs";
6
6
  import "./chunk-NBCHK76Q.mjs";
7
7
  import "./chunk-DR3HJ6BV.mjs";
8
- import "./chunk-GIO2JLKT.mjs";
8
+ import "./chunk-VNZHLLJE.mjs";
9
9
  import "./chunk-3TPCJCVO.mjs";
10
10
  import "./chunk-7P6ASYW6.mjs";
11
11
  export {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  resolveId
3
- } from "./chunk-DVJ3XGXS.mjs";
3
+ } from "./chunk-Z2S7TL5U.mjs";
4
4
  import {
5
5
  createSeedClient
6
- } from "./chunk-W3MTG26Q.mjs";
6
+ } from "./chunk-JODNNMBZ.mjs";
7
7
  import {
8
8
  unpackHmId
9
- } from "./chunk-GIO2JLKT.mjs";
9
+ } from "./chunk-VNZHLLJE.mjs";
10
10
 
11
11
  // src/resource-read.ts
12
12
  async function resolveIdWithClient(rawId, options = {}) {
@@ -7,12 +7,12 @@ import {
7
7
  } from "./chunk-PJ2RFT5A.mjs";
8
8
  import {
9
9
  resolveDocumentState
10
- } from "./chunk-STKAE4YB.mjs";
10
+ } from "./chunk-UTZ42CJC.mjs";
11
11
  import {
12
12
  entityQueryPathToHmIdPath,
13
13
  packHmId,
14
14
  unpackHmId
15
- } from "./chunk-GIO2JLKT.mjs";
15
+ } from "./chunk-VNZHLLJE.mjs";
16
16
 
17
17
  // src/auto-link.ts
18
18
  import { CID } from "multiformats/cid";
@@ -15,7 +15,7 @@ import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-GIO2JLKT.mjs";
18
+ } from "./chunk-VNZHLLJE.mjs";
19
19
 
20
20
  // src/client.ts
21
21
  import { encode as cborEncode } from "@ipld/dag-cbor";
@@ -81,6 +81,9 @@ var QUERY_PARAM_SERIALIZERS = {
81
81
  ListCapabilities: (input) => ({
82
82
  targetId: packHmId(input.targetId)
83
83
  }),
84
+ ListRefs: (input) => ({
85
+ targetId: packHmId(input.targetId)
86
+ }),
84
87
  DiscoveryStatus: (input) => ({
85
88
  uid: input.uid,
86
89
  path: input.path.join("/"),
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packBaseId
10
- } from "./chunk-GIO2JLKT.mjs";
10
+ } from "./chunk-VNZHLLJE.mjs";
11
11
 
12
12
  // src/capability.ts
13
13
  import { base58btc } from "multiformats/bases/base58";
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  hmIdPathToEntityQueryPath,
11
11
  packHmId
12
- } from "./chunk-GIO2JLKT.mjs";
12
+ } from "./chunk-VNZHLLJE.mjs";
13
13
 
14
14
  // src/comment.ts
15
15
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  normalizeQuerySort,
3
3
  unpackHmId
4
- } from "./chunk-GIO2JLKT.mjs";
4
+ } from "./chunk-VNZHLLJE.mjs";
5
5
 
6
6
  // src/blocks-to-markdown.ts
7
7
  import { stringify as stringifyYaml } from "yaml";
@@ -485,10 +485,31 @@ async function contentToResolvedMarkdown(content, options) {
485
485
  }
486
486
  async function documentToResolvedMarkdownWithContext(doc, ctx) {
487
487
  const lines = [emitFrontmatter(doc.metadata || {})];
488
- const body = await blockNodesToResolvedMarkdown(doc.content || [], ctx);
488
+ const body = await blockNodesToResolvedMarkdown(resolvedDocumentContent(doc), ctx);
489
489
  if (body) lines.push(body);
490
490
  return lines.join("\n");
491
491
  }
492
+ function resolvedDocumentContent(doc) {
493
+ var _a, _b;
494
+ const content = doc.content || [];
495
+ const root = content[0];
496
+ if (!doc.account || content.length !== 1 || (root == null ? void 0 : root.block.type) !== "Query") return content;
497
+ const query = (_a = root.block.attributes) == null ? void 0 : _a.query;
498
+ const include = (_b = query == null ? void 0 : query.includes) == null ? void 0 : _b[0];
499
+ if ((query == null ? void 0 : query.includes.length) !== 1 || !include || include.space || include.path) return content;
500
+ return [
501
+ {
502
+ ...root,
503
+ block: {
504
+ ...root.block,
505
+ attributes: {
506
+ ...root.block.attributes,
507
+ query: { ...query, includes: [{ ...include, space: doc.account, path: doc.path }] }
508
+ }
509
+ }
510
+ }
511
+ ];
512
+ }
492
513
  async function blockNodesToResolvedMarkdown(nodes, ctx) {
493
514
  const lines = [];
494
515
  for (const node of nodes) {
@@ -590,7 +611,7 @@ async function resolveBlockEmbed(block, depth, ctx) {
590
611
  }
591
612
  }
592
613
  async function resolveQuery(block, depth, ctx) {
593
- var _a;
614
+ var _a, _b;
594
615
  const ind = resolvedIndent(depth);
595
616
  try {
596
617
  const attrs = block.attributes;
@@ -599,6 +620,7 @@ async function resolveQuery(block, depth, ctx) {
599
620
  let sort;
600
621
  let limit;
601
622
  if (queryConfig == null ? void 0 : queryConfig.includes) {
623
+ if (!((_a = queryConfig.includes[0]) == null ? void 0 : _a.space)) return ind + "<!-- Query: no space specified -->";
602
624
  includes = queryConfig.includes.map((inc) => ({
603
625
  space: inc.space,
604
626
  path: inc.path,
@@ -623,10 +645,10 @@ async function resolveQuery(block, depth, ctx) {
623
645
  sort: (sort == null ? void 0 : sort.length) ? sort : [{ term: "updated", reverse: true }],
624
646
  limit: limit || 10
625
647
  });
626
- if (!((_a = results == null ? void 0 : results.results) == null ? void 0 : _a.length)) return ind + "<!-- Query: no results -->";
648
+ if (!((_b = results == null ? void 0 : results.results) == null ? void 0 : _b.length)) return ind + "<!-- Query: no results -->";
627
649
  return results.results.map((doc) => {
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;
650
+ var _a2, _b2;
651
+ const name = ((_a2 = doc.metadata) == null ? void 0 : _a2.name) || ((_b2 = doc.id.path) == null ? void 0 : _b2.join("/")) || doc.id.uid;
630
652
  return ind + `- [${name}](${doc.id.id})`;
631
653
  }).join("\n");
632
654
  } catch (error) {
@@ -716,7 +738,7 @@ async function resolveEmbeddedResource(link, ctx) {
716
738
  resolved = {
717
739
  label: ((_a = resource.document.metadata) == null ? void 0 : _a.name) || fallbackDocLabel(id),
718
740
  type: "document",
719
- content: resource.document.content || [],
741
+ content: resolvedDocumentContent(resource.document),
720
742
  version: id.version || resource.document.version,
721
743
  latestVersion: resource.document.version
722
744
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  packHmId,
3
3
  unpackHmId
4
- } from "./chunk-GIO2JLKT.mjs";
4
+ } from "./chunk-VNZHLLJE.mjs";
5
5
 
6
6
  // src/document-state.ts
7
7
  async function resolveDocumentState(client, targetId) {
@@ -1085,6 +1085,31 @@ var HMListCapabilitiesRequestSchema = z.object({
1085
1085
  input: HMListCapabilitiesInputSchema,
1086
1086
  output: HMListCapabilitiesOutputSchema
1087
1087
  });
1088
+ var HMRawRefSchema = z.object({
1089
+ id: z.string().optional(),
1090
+ account: z.string().optional(),
1091
+ path: z.string().optional(),
1092
+ target: z.object({
1093
+ version: z.object({ genesis: z.string().optional(), version: z.string().optional() }).optional(),
1094
+ redirect: z.object({ account: z.string().optional(), path: z.string().optional(), republish: z.boolean().optional() }).optional(),
1095
+ tombstone: z.object({}).optional()
1096
+ }).optional(),
1097
+ signer: z.string().optional(),
1098
+ capability: z.string().optional(),
1099
+ timestamp: z.string().optional(),
1100
+ generationInfo: z.object({ genesis: z.string().optional(), generation: z.string().optional() }).optional()
1101
+ });
1102
+ var HMListRefsOutputSchema = z.object({
1103
+ refs: z.array(HMRawRefSchema)
1104
+ });
1105
+ var HMListRefsInputSchema = z.object({
1106
+ targetId: unpackedHmIdSchema
1107
+ });
1108
+ var HMListRefsRequestSchema = z.object({
1109
+ key: z.literal("ListRefs"),
1110
+ input: HMListRefsInputSchema,
1111
+ output: HMListRefsOutputSchema
1112
+ });
1088
1113
  var HMListDocumentCollaboratorsInputSchema = z.object({
1089
1114
  targetId: unpackedHmIdSchema
1090
1115
  });
@@ -1295,6 +1320,7 @@ var HMGetRequestSchema = z.discriminatedUnion("key", [
1295
1320
  HMListCitationsRequestSchema,
1296
1321
  HMListChangesRequestSchema,
1297
1322
  HMListCapabilitiesRequestSchema,
1323
+ HMListRefsRequestSchema,
1298
1324
  HMListDocumentCollaboratorsRequestSchema,
1299
1325
  HMInteractionSummaryRequestSchema,
1300
1326
  HMListCommentVersionsRequestSchema,
@@ -1328,6 +1354,7 @@ var HMRequestSchema = z.discriminatedUnion("key", [
1328
1354
  HMListCitationsRequestSchema,
1329
1355
  HMListChangesRequestSchema,
1330
1356
  HMListCapabilitiesRequestSchema,
1357
+ HMListRefsRequestSchema,
1331
1358
  HMListDocumentCollaboratorsRequestSchema,
1332
1359
  HMInteractionSummaryRequestSchema,
1333
1360
  HMListCommentVersionsRequestSchema,
@@ -1642,6 +1669,10 @@ export {
1642
1669
  HMListCapabilitiesOutputSchema,
1643
1670
  HMListCapabilitiesInputSchema,
1644
1671
  HMListCapabilitiesRequestSchema,
1672
+ HMRawRefSchema,
1673
+ HMListRefsOutputSchema,
1674
+ HMListRefsInputSchema,
1675
+ HMListRefsRequestSchema,
1645
1676
  HMListDocumentCollaboratorsInputSchema,
1646
1677
  HMListDocumentCollaboratorsOutputSchema,
1647
1678
  HMListDocumentCollaboratorsRequestSchema,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  codePointLength
3
- } from "./chunk-GIO2JLKT.mjs";
3
+ } from "./chunk-VNZHLLJE.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
@@ -6,7 +6,7 @@ import {
6
6
  HMBlockSchema,
7
7
  codePointLength,
8
8
  toNumber
9
- } from "./chunk-GIO2JLKT.mjs";
9
+ } from "./chunk-VNZHLLJE.mjs";
10
10
 
11
11
  // src/editorblock-to-hmblock.ts
12
12
  function toHMBlockType(editorBlockType) {
@@ -2,7 +2,7 @@ import {
2
2
  entityQueryPathToHmIdPath,
3
3
  parseFragment,
4
4
  unpackHmId
5
- } from "./chunk-GIO2JLKT.mjs";
5
+ } from "./chunk-VNZHLLJE.mjs";
6
6
 
7
7
  // src/hm-resolver.ts
8
8
  async function resolveHypermediaUrl(url, opts) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSurrogate
3
- } from "./chunk-GIO2JLKT.mjs";
3
+ } from "./chunk-VNZHLLJE.mjs";
4
4
 
5
5
  // src/hmblock-to-editorblock.ts
6
6
  function toEditorBlockType(hmBlockType) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-ZVJGJE2L.mjs";
3
+ } from "./chunk-W7AGZEC2.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-2FJBS3V7.mjs";
package/dist/client.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createSeedClient,
3
3
  deserializeQueryString
4
- } from "./chunk-W3MTG26Q.mjs";
4
+ } from "./chunk-JODNNMBZ.mjs";
5
5
  import "./chunk-CBELM7KX.mjs";
6
6
  import "./chunk-O5MHN2EO.mjs";
7
7
  import "./chunk-PJ2RFT5A.mjs";
8
8
  import "./chunk-LVAHHQIK.mjs";
9
9
  import "./chunk-DR3HJ6BV.mjs";
10
- import "./chunk-GIO2JLKT.mjs";
10
+ import "./chunk-VNZHLLJE.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-7QKG43UV.mjs";
7
+ } from "./chunk-T7WF36LU.mjs";
8
8
  import "./chunk-JKKS35IS.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
11
- import "./chunk-GIO2JLKT.mjs";
11
+ import "./chunk-VNZHLLJE.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-STKAE4YB.mjs";
8
- import "./chunk-GIO2JLKT.mjs";
7
+ } from "./chunk-UTZ42CJC.mjs";
8
+ import "./chunk-VNZHLLJE.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-GN76IN3M.mjs";
4
+ } from "./chunk-XXUI3VKA.mjs";
5
5
  import "./chunk-JKKS35IS.mjs";
6
- import "./chunk-GIO2JLKT.mjs";
6
+ import "./chunk-VNZHLLJE.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-DVJ3XGXS.mjs";
5
- import "./chunk-GIO2JLKT.mjs";
4
+ } from "./chunk-Z2S7TL5U.mjs";
5
+ import "./chunk-VNZHLLJE.mjs";
6
6
  import "./chunk-7P6ASYW6.mjs";
7
7
  export {
8
8
  resolveHypermediaUrl,