@seed-hypermedia/client 0.0.135 → 0.0.136

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.
Files changed (45) hide show
  1. package/dist/apps.mjs +6 -6
  2. package/dist/auto-link.mjs +4 -4
  3. package/dist/block-diff.mjs +4 -4
  4. package/dist/blocks-to-markdown.mjs +3 -3
  5. package/dist/capability.mjs +2 -2
  6. package/dist/{chunk-QFIEZZYJ.mjs → chunk-4CLAG2ZO.mjs} +2 -2
  7. package/dist/{chunk-U5K6COJT.mjs → chunk-5CYFQIM3.mjs} +2 -2
  8. package/dist/{chunk-QS6PIRUE.mjs → chunk-5DRX6MJ6.mjs} +1 -1
  9. package/dist/{chunk-H2R4GYNV.mjs → chunk-6HOMACAF.mjs} +1 -1
  10. package/dist/{chunk-FU7FIYHI.mjs → chunk-7SM52PZ4.mjs} +1 -1
  11. package/dist/{chunk-KAZNQFXV.mjs → chunk-BIUZ2PNE.mjs} +1 -1
  12. package/dist/{chunk-YRNPRWYG.mjs → chunk-FQNFKGLA.mjs} +1 -1
  13. package/dist/{chunk-7FPJWOXB.mjs → chunk-HWXF5HWC.mjs} +1 -1
  14. package/dist/{chunk-LDCWJXIP.mjs → chunk-KCSNLBCS.mjs} +1 -1
  15. package/dist/{chunk-O36UBGLF.mjs → chunk-MUV2CJEU.mjs} +3 -3
  16. package/dist/{chunk-Z7VKSY7P.mjs → chunk-PN4FREGN.mjs} +3 -3
  17. package/dist/{chunk-ETIDW7ZJ.mjs → chunk-UYADUQ6I.mjs} +1 -1
  18. package/dist/{chunk-ZFMYEBAU.mjs → chunk-WTK4IVK5.mjs} +3 -3
  19. package/dist/{chunk-AU3QZNYC.mjs → chunk-X4I2LH7P.mjs} +1 -1
  20. package/dist/{chunk-Q7CWMEBZ.mjs → chunk-XL4OR2M2.mjs} +1 -1
  21. package/dist/{chunk-HL43SJUP.mjs → chunk-YFIEJK62.mjs} +26 -4
  22. package/dist/{chunk-DGNAMVGH.mjs → chunk-YSTZP4QT.mjs} +19 -1
  23. package/dist/{chunk-IFELP3LQ.mjs → chunk-ZPRXUG5Y.mjs} +1 -1
  24. package/dist/client.mjs +2 -2
  25. package/dist/comment.d.ts +4 -1
  26. package/dist/comment.mjs +2 -2
  27. package/dist/document-state.mjs +2 -2
  28. package/dist/editorblock-to-hmblock.mjs +2 -2
  29. package/dist/hm-resolver.mjs +2 -2
  30. package/dist/hm-types.d.ts +388 -0
  31. package/dist/hm-types.mjs +3 -1
  32. package/dist/hmblock-to-editorblock.mjs +2 -2
  33. package/dist/index.mjs +15 -15
  34. package/dist/pdf-to-blocks.mjs +3 -3
  35. package/dist/prepare-change.mjs +3 -3
  36. package/dist/resource-read.mjs +4 -4
  37. package/dist/schema-engine.mjs +2 -2
  38. package/dist/schema-registry.generated.mjs +1 -1
  39. package/dist/schema-resolve.mjs +4 -4
  40. package/dist/schema-subtypes.mjs +4 -4
  41. package/dist/schema-types.generated.d.ts +5 -3
  42. package/dist/signed-blob.mjs +2 -2
  43. package/dist/tei-to-blocks.mjs +2 -2
  44. package/dist/unicode.mjs +1 -1
  45. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  packHmId,
3
3
  unpackHmId
4
- } from "./chunk-DGNAMVGH.mjs";
4
+ } from "./chunk-YSTZP4QT.mjs";
5
5
 
6
6
  // src/document-state.ts
7
7
  async function resolveDocumentState(client, targetId) {
@@ -15,7 +15,7 @@ import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-DGNAMVGH.mjs";
18
+ } from "./chunk-YSTZP4QT.mjs";
19
19
 
20
20
  // src/client.ts
21
21
  import { encode as cborEncode } from "@ipld/dag-cbor";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  codePointLength
3
- } from "./chunk-DGNAMVGH.mjs";
3
+ } from "./chunk-YSTZP4QT.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sameDocumentVersion
3
- } from "./chunk-QS6PIRUE.mjs";
3
+ } from "./chunk-5DRX6MJ6.mjs";
4
4
  import {
5
5
  SeedClientError
6
6
  } from "./chunk-CBELM7KX.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-FU7FIYHI.mjs";
3
+ } from "./chunk-7SM52PZ4.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-2FJBS3V7.mjs";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-4ELQ4LJL.mjs";
4
4
  import {
5
5
  blocksToMarkdown
6
- } from "./chunk-QFIEZZYJ.mjs";
6
+ } from "./chunk-4CLAG2ZO.mjs";
7
7
 
8
8
  // src/block-diff.ts
9
9
  function createBlocksMap(nodes, parentId = "") {
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packBaseId
10
- } from "./chunk-DGNAMVGH.mjs";
10
+ } from "./chunk-YSTZP4QT.mjs";
11
11
 
12
12
  // src/capability.ts
13
13
  import { base58btc } from "multiformats/bases/base58";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  documentUpdateBlobs
3
- } from "./chunk-KAZNQFXV.mjs";
3
+ } from "./chunk-BIUZ2PNE.mjs";
4
4
  import {
5
5
  resolveDocumentState
6
- } from "./chunk-QS6PIRUE.mjs";
6
+ } from "./chunk-5DRX6MJ6.mjs";
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packHmId,
10
10
  unpackHmId
11
- } from "./chunk-DGNAMVGH.mjs";
11
+ } from "./chunk-YSTZP4QT.mjs";
12
12
 
13
13
  // src/auto-link.ts
14
14
  function documentContainsLinkToChild(document, childId) {
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  createSeedClient
3
- } from "./chunk-H2R4GYNV.mjs";
3
+ } from "./chunk-6HOMACAF.mjs";
4
4
  import {
5
5
  extractCommentIdFromUrl,
6
6
  hmDomainUrlToWebUrl,
7
7
  resolveId
8
- } from "./chunk-Q7CWMEBZ.mjs";
8
+ } from "./chunk-XL4OR2M2.mjs";
9
9
  import {
10
10
  unpackHmId
11
- } from "./chunk-DGNAMVGH.mjs";
11
+ } from "./chunk-YSTZP4QT.mjs";
12
12
 
13
13
  // src/resource-read.ts
14
14
  async function resolveIdWithClient(rawId, options = {}) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getSupportedHMQueryFilters,
3
3
  isSurrogate
4
- } from "./chunk-DGNAMVGH.mjs";
4
+ } from "./chunk-YSTZP4QT.mjs";
5
5
 
6
6
  // src/hmblock-to-editorblock.ts
7
7
  function toEditorBlockType(hmBlockType) {
@@ -12,17 +12,17 @@ import {
12
12
  schemaForCid,
13
13
  structFields,
14
14
  validate
15
- } from "./chunk-AU3QZNYC.mjs";
15
+ } from "./chunk-X4I2LH7P.mjs";
16
16
  import {
17
17
  HM_SCHEMAS
18
- } from "./chunk-U5K6COJT.mjs";
18
+ } from "./chunk-5CYFQIM3.mjs";
19
19
  import {
20
20
  parseCidString
21
21
  } from "./chunk-VWSAFDOL.mjs";
22
22
  import {
23
23
  packHmId,
24
24
  unpackHmId
25
- } from "./chunk-DGNAMVGH.mjs";
25
+ } from "./chunk-YSTZP4QT.mjs";
26
26
 
27
27
  // src/schema-resolve.ts
28
28
  var DAG_CBOR_CODE = 113;
@@ -2,7 +2,7 @@ import {
2
2
  HM_SCHEMAS,
3
3
  HM_SCHEMA_MANIFEST,
4
4
  HM_SCHEMA_PAGES
5
- } from "./chunk-U5K6COJT.mjs";
5
+ } from "./chunk-5CYFQIM3.mjs";
6
6
 
7
7
  // src/schema-engine.ts
8
8
  var LIBRARY_AUTHORITY = "hyper.media";
@@ -2,7 +2,7 @@ import {
2
2
  entityQueryPathToHmIdPath,
3
3
  parseFragment,
4
4
  unpackHmId
5
- } from "./chunk-DGNAMVGH.mjs";
5
+ } from "./chunk-YSTZP4QT.mjs";
6
6
  import {
7
7
  pageParamsFromUrl
8
8
  } from "./chunk-AHQWDCHV.mjs";
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  hmIdPathToEntityQueryPath,
11
11
  packHmId
12
- } from "./chunk-DGNAMVGH.mjs";
12
+ } from "./chunk-YSTZP4QT.mjs";
13
13
 
14
14
  // src/comment.ts
15
15
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -221,11 +221,15 @@ function deepStripUndefined(value) {
221
221
  }
222
222
  return value;
223
223
  }
224
+ function bytesEqual(a, b) {
225
+ return a.length === b.length && a.every((value, index) => value === b[index]);
226
+ }
224
227
  function createUnsignedComment({
225
228
  content,
226
229
  docId,
227
230
  docVersion,
228
231
  signerKey,
232
+ account,
229
233
  replyCommentVersion,
230
234
  rootReplyCommentVersion,
231
235
  visibility
@@ -242,6 +246,10 @@ function createUnsignedComment({
242
246
  replyParent: replyCommentVersion || void 0,
243
247
  threadRoot: rootReplyCommentVersion || void 0
244
248
  };
249
+ if (account) {
250
+ const accountKey = new Uint8Array(base58btc.decode(account));
251
+ if (!bytesEqual(accountKey, signerKey)) unsignedComment.account = accountKey;
252
+ }
245
253
  if (!unsignedComment.replyParent) delete unsignedComment.replyParent;
246
254
  if (!unsignedComment.threadRoot) delete unsignedComment.threadRoot;
247
255
  if (visibility) unsignedComment.visibility = visibility;
@@ -262,6 +270,7 @@ async function createCommentBlob({
262
270
  docId,
263
271
  docVersion,
264
272
  signer,
273
+ account,
265
274
  replyCommentVersion,
266
275
  rootReplyCommentVersion,
267
276
  visibility
@@ -273,6 +282,7 @@ async function createCommentBlob({
273
282
  docId,
274
283
  docVersion,
275
284
  signerKey,
285
+ account,
276
286
  replyCommentVersion,
277
287
  rootReplyCommentVersion,
278
288
  visibility
@@ -342,6 +352,7 @@ async function createComment(input, signer) {
342
352
  docId: input.docId,
343
353
  docVersion: input.docVersion,
344
354
  signer,
355
+ account: input.account,
345
356
  replyCommentVersion: input.replyCommentVersion,
346
357
  rootReplyCommentVersion: input.rootReplyCommentVersion,
347
358
  visibility: input.visibility
@@ -350,8 +361,9 @@ async function createComment(input, signer) {
350
361
  }
351
362
  async function deleteComment(input, signer) {
352
363
  const parts = input.commentId.split("/");
364
+ const authority = parts[0];
353
365
  const tsid = parts[1];
354
- if (!tsid) {
366
+ if (!authority || !tsid) {
355
367
  throw new Error(`Invalid comment ID format: ${input.commentId}`);
356
368
  }
357
369
  const signerKey = await signerPublicKey(signer);
@@ -366,6 +378,8 @@ async function deleteComment(input, signer) {
366
378
  ts: BigInt(Date.now()),
367
379
  sig: new Uint8Array(64)
368
380
  };
381
+ const authorityKey = new Uint8Array(base58btc.decode(authority));
382
+ if (!bytesEqual(authorityKey, signerKey)) tombstone.account = authorityKey;
369
383
  if (input.visibility) tombstone.visibility = input.visibility;
370
384
  const cleanedTombstone = deepStripUndefined(tombstone);
371
385
  cleanedTombstone.sig = await signObject(signer, cleanedTombstone);
@@ -374,8 +388,9 @@ async function deleteComment(input, signer) {
374
388
  }
375
389
  async function updateComment(input, signer) {
376
390
  const parts = input.commentId.split("/");
391
+ const authority = parts[0];
377
392
  const tsid = parts[1];
378
- if (!tsid) {
393
+ if (!authority || !tsid) {
379
394
  throw new Error(`Invalid comment ID format: ${input.commentId}`);
380
395
  }
381
396
  const signerKey = await signerPublicKey(signer);
@@ -392,6 +407,8 @@ async function updateComment(input, signer) {
392
407
  ts: BigInt(Date.now()),
393
408
  sig: new Uint8Array(64)
394
409
  };
410
+ const authorityKey = new Uint8Array(base58btc.decode(authority));
411
+ if (!bytesEqual(authorityKey, signerKey)) comment.account = authorityKey;
395
412
  if (input.replyParentVersion) comment.replyParent = CID.parse(input.replyParentVersion);
396
413
  if (input.rootReplyCommentVersion) comment.threadRoot = CID.parse(input.rootReplyCommentVersion);
397
414
  if (input.visibility) comment.visibility = input.visibility;
@@ -406,8 +423,13 @@ async function commentRecordIdFromBlob(blobData) {
406
423
  throw new Error(`Expected Comment blob, got "${decoded.type}"`);
407
424
  }
408
425
  const signerBytes = decoded.signer;
426
+ const accountBytes = decoded.account;
409
427
  const ts = BigInt(decoded.ts);
410
- const authority = base58btc.encode(new Uint8Array(signerBytes));
428
+ const authority = base58btc.encode(new Uint8Array(accountBytes || signerBytes));
429
+ const existingTSID = decoded.id;
430
+ if (typeof existingTSID === "string" && existingTSID) {
431
+ return `${authority}/${existingTSID}`;
432
+ }
411
433
  const buf = new ArrayBuffer(8);
412
434
  new DataView(buf).setBigUint64(0, ts, false);
413
435
  const tsBytes = new Uint8Array(buf, 2, 6);
@@ -477,6 +477,11 @@ var HMDocumentInfoSchema = z.object({
477
477
  // full document. Undefined = not derived (yet); empty string = derived, the
478
478
  // document has no content image (cards skip their fallback fetch).
479
479
  firstImageInContent: z.string().optional(),
480
+ /**
481
+ * Indexer-derived hm:// IDs of the documents the published version links as latest-following Card embeds, in
482
+ * reading order. The sidebar is built from them. The indexer derives them for every document.
483
+ */
484
+ navigationCards: z.array(z.string()).optional(),
480
485
  visibility: HMResourceVisibilitySchema
481
486
  });
482
487
  var HMQueryResultSchema = z.object({
@@ -667,7 +672,12 @@ var HMDocumentSchema = z.object({
667
672
  detachedBlocks: z.record(z.string(), HMBlockNodeSchema).optional(),
668
673
  genesis: z.string(),
669
674
  generationInfo: HMGenerationInfoSchema.optional(),
670
- visibility: HMResourceVisibilitySchema
675
+ visibility: HMResourceVisibilitySchema,
676
+ /**
677
+ * hm:// IDs of the documents this version links as latest-following Card embeds, in reading order. Derived by the
678
+ * backend, the same way as `HMDocumentInfo.navigationCards`.
679
+ */
680
+ navigationCards: z.array(z.string()).optional()
671
681
  });
672
682
  var HMResourceDocumentSchema = z.object({
673
683
  type: z.literal("document"),
@@ -906,6 +916,11 @@ var HMResourceMetadataRequestSchema = z.object({
906
916
  input: unpackedHmIdSchema,
907
917
  output: HMMetadataPayloadSchema
908
918
  });
919
+ var HMDocumentInfoRequestSchema = z.object({
920
+ key: z.literal("DocumentInfo"),
921
+ input: unpackedHmIdSchema,
922
+ output: HMDocumentInfoSchema.nullable()
923
+ });
909
924
  var HMAccountRequestSchema = z.object({
910
925
  key: z.literal("Account"),
911
926
  input: z.string(),
@@ -1535,6 +1550,7 @@ var HMDiscoveryStatusRequestSchema = z.object({
1535
1550
  var HMGetRequestSchema = z.discriminatedUnion("key", [
1536
1551
  HMResourceRequestSchema,
1537
1552
  HMResourceMetadataRequestSchema,
1553
+ HMDocumentInfoRequestSchema,
1538
1554
  HMAccountRequestSchema,
1539
1555
  HMCommentRequestSchema,
1540
1556
  HMSearchRequestSchema,
@@ -1575,6 +1591,7 @@ var HMRequestSchema = z.discriminatedUnion("key", [
1575
1591
  HMListDocumentAttributeNamesRequestSchema,
1576
1592
  HMListDocumentAttributeValuesRequestSchema,
1577
1593
  HMResourceMetadataRequestSchema,
1594
+ HMDocumentInfoRequestSchema,
1578
1595
  HMAccountRequestSchema,
1579
1596
  HMCommentRequestSchema,
1580
1597
  HMSearchRequestSchema,
@@ -1873,6 +1890,7 @@ export {
1873
1890
  HMSubjectContactsRequestSchema,
1874
1891
  HMResourceRequestSchema,
1875
1892
  HMResourceMetadataRequestSchema,
1893
+ HMDocumentInfoRequestSchema,
1876
1894
  HMAccountRequestSchema,
1877
1895
  HMCommentRequestSchema,
1878
1896
  HMSearchInputSchema,
@@ -7,7 +7,7 @@ import {
7
7
  codePointLength,
8
8
  parseHMQueryFiltersJSON,
9
9
  toNumber
10
- } from "./chunk-DGNAMVGH.mjs";
10
+ } from "./chunk-YSTZP4QT.mjs";
11
11
 
12
12
  // src/editorblock-to-hmblock.ts
13
13
  function toHMBlockType(editorBlockType) {
package/dist/client.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createSeedClient,
3
3
  deserializeQueryString
4
- } from "./chunk-H2R4GYNV.mjs";
4
+ } from "./chunk-6HOMACAF.mjs";
5
5
  import "./chunk-CBELM7KX.mjs";
6
6
  import "./chunk-KM2NR4YA.mjs";
7
7
  import "./chunk-PJ2RFT5A.mjs";
8
8
  import "./chunk-LVAHHQIK.mjs";
9
9
  import "./chunk-DR3HJ6BV.mjs";
10
- import "./chunk-DGNAMVGH.mjs";
10
+ import "./chunk-YSTZP4QT.mjs";
11
11
  import "./chunk-AHQWDCHV.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
package/dist/comment.d.ts CHANGED
@@ -36,6 +36,8 @@ type CreateCommentBaseInput = {
36
36
  /** Deprecated: pass `quoting: {blockId}` instead. Still honored for back-compat. */
37
37
  quotingBlockId?: string;
38
38
  visibility?: 'Private' | '';
39
+ /** Stable account authority represented by a delegated signer. */
40
+ account?: string;
39
41
  };
40
42
  export type CreateCommentInput = (CreateCommentBaseInput & {
41
43
  content: HMBlockNode[];
@@ -71,7 +73,8 @@ export type UpdateCommentInput = {
71
73
  export declare function updateComment(input: UpdateCommentInput, signer: AnySigner): Promise<HMPublishBlobsInput>;
72
74
  /**
73
75
  * Compute the record ID ("authority/tsid") from raw CBOR-encoded comment blob bytes.
74
- * The TSID is a 10-byte base58btc value: 6 bytes ms timestamp + 4 bytes SHA256 prefix.
76
+ * Edits and tombstones carry the original TSID in `id`. A creation derives its
77
+ * 10-byte base58btc TSID from 6 timestamp bytes and a 4-byte SHA256 prefix.
75
78
  */
76
79
  export declare function commentRecordIdFromBlob(blobData: Uint8Array): Promise<string>;
77
80
  export {};
package/dist/comment.mjs CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  deleteComment,
5
5
  trimTrailingEmptyBlocks,
6
6
  updateComment
7
- } from "./chunk-HL43SJUP.mjs";
7
+ } from "./chunk-YFIEJK62.mjs";
8
8
  import "./chunk-JKKS35IS.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
11
- import "./chunk-DGNAMVGH.mjs";
11
+ import "./chunk-YSTZP4QT.mjs";
12
12
  import "./chunk-AHQWDCHV.mjs";
13
13
  import "./chunk-7P6ASYW6.mjs";
14
14
  export {
@@ -6,8 +6,8 @@ import {
6
6
  resolveDocumentState,
7
7
  resolveEditableDocument,
8
8
  sameDocumentVersion
9
- } from "./chunk-QS6PIRUE.mjs";
10
- import "./chunk-DGNAMVGH.mjs";
9
+ } from "./chunk-5DRX6MJ6.mjs";
10
+ import "./chunk-YSTZP4QT.mjs";
11
11
  import "./chunk-AHQWDCHV.mjs";
12
12
  import "./chunk-7P6ASYW6.mjs";
13
13
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  editorBlockToHMBlock,
3
3
  editorBlocksToHMBlockNodes
4
- } from "./chunk-IFELP3LQ.mjs";
4
+ } from "./chunk-ZPRXUG5Y.mjs";
5
5
  import "./chunk-JKKS35IS.mjs";
6
- import "./chunk-DGNAMVGH.mjs";
6
+ import "./chunk-YSTZP4QT.mjs";
7
7
  import "./chunk-AHQWDCHV.mjs";
8
8
  import "./chunk-7P6ASYW6.mjs";
9
9
  export {
@@ -3,8 +3,8 @@ import {
3
3
  hmDomainUrlToWebUrl,
4
4
  resolveHypermediaUrl,
5
5
  resolveId
6
- } from "./chunk-Q7CWMEBZ.mjs";
7
- import "./chunk-DGNAMVGH.mjs";
6
+ } from "./chunk-XL4OR2M2.mjs";
7
+ import "./chunk-YSTZP4QT.mjs";
8
8
  import "./chunk-AHQWDCHV.mjs";
9
9
  import "./chunk-7P6ASYW6.mjs";
10
10
  export {