@seed-hypermedia/client 0.0.109 → 0.0.110

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 (47) hide show
  1. package/dist/auto-link.mjs +4 -3
  2. package/dist/blocks-to-markdown.mjs +3 -2
  3. package/dist/capability.d.ts +9 -3
  4. package/dist/capability.mjs +3 -2
  5. package/dist/{chunk-34OBOF5O.mjs → chunk-3Y2LUQ2S.mjs} +1 -1
  6. package/dist/{chunk-Z3J6R5DN.mjs → chunk-4MLSRAHT.mjs} +1 -1
  7. package/dist/{chunk-2NM2JP5H.mjs → chunk-5N4GUBTC.mjs} +3 -3
  8. package/dist/{chunk-VN7F33SS.mjs → chunk-65UV5O57.mjs} +38 -0
  9. package/dist/chunk-AHQWDCHV.mjs +56 -0
  10. package/dist/{chunk-ICFYYWGD.mjs → chunk-APDALLCQ.mjs} +1 -1
  11. package/dist/{chunk-52RP7HHW.mjs → chunk-AUKAVTTK.mjs} +1 -1
  12. package/dist/{chunk-7IISPGNN.mjs → chunk-FPANFJPK.mjs} +23 -5
  13. package/dist/{chunk-GWV7ETLU.mjs → chunk-JITFCBJG.mjs} +2 -2
  14. package/dist/{chunk-IAS2V6ON.mjs → chunk-JXIRASEP.mjs} +1 -1
  15. package/dist/{chunk-KOQHARP5.mjs → chunk-JZO5T6RZ.mjs} +1 -1
  16. package/dist/{chunk-Y5XKORRF.mjs → chunk-MLR4UDOJ.mjs} +3 -3
  17. package/dist/{chunk-HLTKEZ7W.mjs → chunk-N2DIEFL4.mjs} +1 -1
  18. package/dist/{chunk-KNA3PBET.mjs → chunk-OBJQE4NK.mjs} +1 -1
  19. package/dist/{chunk-5MVCUZBD.mjs → chunk-ONSB56Z7.mjs} +6 -1
  20. package/dist/{chunk-G7CFO5W3.mjs → chunk-U3PAJ472.mjs} +1 -1
  21. package/dist/{chunk-BHESE4LH.mjs → chunk-XBZWF34J.mjs} +3 -3
  22. package/dist/{chunk-SQFGEPOQ.mjs → chunk-ZIWKVJCO.mjs} +10 -5
  23. package/dist/client.mjs +3 -2
  24. package/dist/comment.mjs +3 -2
  25. package/dist/document-state.mjs +3 -2
  26. package/dist/editorblock-to-hmblock.mjs +3 -2
  27. package/dist/file-to-ipfs.d.ts +19 -0
  28. package/dist/file-to-ipfs.mjs +5 -1
  29. package/dist/hm-resolver.mjs +3 -2
  30. package/dist/hm-types.d.ts +4522 -101
  31. package/dist/hm-types.mjs +2 -1
  32. package/dist/hmblock-to-editorblock.mjs +3 -2
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.mjs +19 -14
  35. package/dist/page-input.d.ts +13 -0
  36. package/dist/page-input.mjs +15 -0
  37. package/dist/pdf-to-blocks.mjs +4 -3
  38. package/dist/resource-read.mjs +5 -4
  39. package/dist/schema-engine.mjs +2 -2
  40. package/dist/schema-registry.generated.mjs +1 -1
  41. package/dist/schema-resolve.mjs +5 -4
  42. package/dist/schema-subtypes.mjs +5 -4
  43. package/dist/schema-types.generated.d.ts +24 -0
  44. package/dist/signed-blob.mjs +2 -2
  45. package/dist/tei-to-blocks.mjs +3 -2
  46. package/dist/unicode.mjs +2 -1
  47. package/package.json +1 -1
@@ -4,13 +4,14 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-GWV7ETLU.mjs";
7
+ } from "./chunk-JITFCBJG.mjs";
8
8
  import "./chunk-O5MHN2EO.mjs";
9
9
  import "./chunk-PJ2RFT5A.mjs";
10
- import "./chunk-ICFYYWGD.mjs";
10
+ import "./chunk-APDALLCQ.mjs";
11
11
  import "./chunk-LVAHHQIK.mjs";
12
12
  import "./chunk-DR3HJ6BV.mjs";
13
- import "./chunk-7IISPGNN.mjs";
13
+ import "./chunk-FPANFJPK.mjs";
14
+ import "./chunk-AHQWDCHV.mjs";
14
15
  import "./chunk-7P6ASYW6.mjs";
15
16
  export {
16
17
  autoLinkChildToParent,
@@ -7,8 +7,9 @@ import {
7
7
  emitFrontmatter,
8
8
  parseDraftFilename,
9
9
  slugify
10
- } from "./chunk-HLTKEZ7W.mjs";
11
- import "./chunk-7IISPGNN.mjs";
10
+ } from "./chunk-N2DIEFL4.mjs";
11
+ import "./chunk-FPANFJPK.mjs";
12
+ import "./chunk-AHQWDCHV.mjs";
12
13
  import "./chunk-7P6ASYW6.mjs";
13
14
  export {
14
15
  blocksToMarkdown,
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Capability SDK — create and resolve capabilities (delegate access to other accounts).
3
3
  */
4
- import type { HMPublishBlobsInput } from './hm-types';
4
+ import type { HMPublishBlobsInput, HMRequest } from './hm-types';
5
5
  import type { AnySigner } from './signer';
6
- import type { SeedClient } from './client';
7
6
  /** Role values for capability blobs. */
8
7
  export type CapabilityRole = 'WRITER' | 'AGENT';
9
8
  export type CreateCapabilityInput = {
@@ -32,5 +31,12 @@ export declare function createCapability(input: CreateCapabilityInput, signer: A
32
31
  * @param path - The document path being written to (e.g. "/podcasts"). When provided,
33
32
  * ListCapabilities is queried with this path so the backend returns capabilities
34
33
  * scoped to that path (or any ancestor path that covers it).
34
+ * @param capability - When supplied, resolve only this existing capability.
35
35
  */
36
- export declare function resolveCapability(client: SeedClient, targetAccount: string, signerAccount: string, path?: string): Promise<string | undefined>;
36
+ export declare function resolveCapability(client: {
37
+ request: (key: 'ListCapabilities', input: Extract<HMRequest, {
38
+ key: 'ListCapabilities';
39
+ }>['input']) => Promise<Extract<HMRequest, {
40
+ key: 'ListCapabilities';
41
+ }>['output']>;
42
+ }, targetAccount: string, signerAccount: string, path?: string, capability?: string): Promise<string | undefined>;
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  createCapability,
3
3
  resolveCapability
4
- } from "./chunk-SQFGEPOQ.mjs";
4
+ } from "./chunk-ZIWKVJCO.mjs";
5
5
  import "./chunk-LVAHHQIK.mjs";
6
6
  import "./chunk-NBCHK76Q.mjs";
7
7
  import "./chunk-DR3HJ6BV.mjs";
8
- import "./chunk-7IISPGNN.mjs";
8
+ import "./chunk-FPANFJPK.mjs";
9
+ import "./chunk-AHQWDCHV.mjs";
9
10
  import "./chunk-3TPCJCVO.mjs";
10
11
  import "./chunk-7P6ASYW6.mjs";
11
12
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-KOQHARP5.mjs";
3
+ } from "./chunk-JZO5T6RZ.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-2FJBS3V7.mjs";
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  hmIdPathToEntityQueryPath,
11
11
  packHmId
12
- } from "./chunk-7IISPGNN.mjs";
12
+ } from "./chunk-FPANFJPK.mjs";
13
13
 
14
14
  // src/comment.ts
15
15
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  resolveId
3
- } from "./chunk-5MVCUZBD.mjs";
3
+ } from "./chunk-ONSB56Z7.mjs";
4
4
  import {
5
5
  createSeedClient
6
- } from "./chunk-IAS2V6ON.mjs";
6
+ } from "./chunk-JXIRASEP.mjs";
7
7
  import {
8
8
  unpackHmId
9
- } from "./chunk-7IISPGNN.mjs";
9
+ } from "./chunk-FPANFJPK.mjs";
10
10
 
11
11
  // src/resource-read.ts
12
12
  async function resolveIdWithClient(rawId, options = {}) {
@@ -38,6 +38,42 @@ async function filesToIpfsBlobs(binaries) {
38
38
  }
39
39
  return { resultCIDs, blobs };
40
40
  }
41
+ async function directoryToIpfsBlobs(files) {
42
+ if (files.length === 0) throw new Error("A folder needs at least one file");
43
+ const seen = /* @__PURE__ */ new Set();
44
+ const entries = files.map((file) => {
45
+ const path = normalizeDirectoryFilePath(file.path);
46
+ if (seen.has(path)) throw new Error(`Duplicate file in folder: ${path}`);
47
+ seen.add(path);
48
+ return { path, content: file.content };
49
+ });
50
+ const blockstore = new MemoryBlockstore();
51
+ let rootCid;
52
+ const blobs = [];
53
+ const published = /* @__PURE__ */ new Set();
54
+ for await (const entry of unixFSImporter(entries, blockstore, { wrapWithDirectory: true })) {
55
+ if (entry.path === "" || entry.path === void 0) rootCid = entry.cid.toString();
56
+ blobs.push({ cid: entry.cid.toString(), data: await blockstore.get(entry.cid) });
57
+ published.add(entry.cid.multihash.digest.join(","));
58
+ }
59
+ if (!rootCid) throw new Error("Failed to build the folder root");
60
+ for await (const pair of blockstore.getAll()) {
61
+ const key = pair.cid.multihash.digest.join(",");
62
+ if (published.has(key)) continue;
63
+ published.add(key);
64
+ blobs.push({ cid: pair.cid.toString(), data: pair.block });
65
+ }
66
+ return { cid: rootCid, blobs };
67
+ }
68
+ function normalizeDirectoryFilePath(path) {
69
+ const segments = path.replace(/\\/g, "/").split("/").filter((segment) => segment !== "" && segment !== ".");
70
+ if (segments.length === 0) throw new Error("A folder file needs a name");
71
+ for (const segment of segments) {
72
+ if (segment === "..") throw new Error(`Invalid folder path: ${path}`);
73
+ if (/[\x00-\x1f]/.test(segment)) throw new Error(`Invalid folder path: ${path}`);
74
+ }
75
+ return segments.join("/");
76
+ }
41
77
  var FILE_PROTOCOL = "file://";
42
78
  function getBlockLink(block) {
43
79
  const b = block;
@@ -103,6 +139,8 @@ function hasFileLinks(nodes) {
103
139
  export {
104
140
  fileToIpfsBlobs,
105
141
  filesToIpfsBlobs,
142
+ directoryToIpfsBlobs,
143
+ normalizeDirectoryFilePath,
106
144
  resolveFileLinksInBlocks,
107
145
  hasFileLinks
108
146
  };
@@ -0,0 +1,56 @@
1
+ // src/page-input.ts
2
+ var PAGE_INPUT_PREFIX = "p.";
3
+ function pageParamsFromUrl(url) {
4
+ const queryStart = url.indexOf("?");
5
+ if (queryStart === -1 || url.indexOf("#") !== -1 && url.indexOf("#") < queryStart) return void 0;
6
+ const params = new URLSearchParams(url.slice(queryStart + 1).split("#")[0]);
7
+ const entries = Array.from(params.entries()).filter(([key]) => key.startsWith(PAGE_INPUT_PREFIX));
8
+ return entries.length ? Object.fromEntries(entries.map(([key, value]) => [key.slice(PAGE_INPUT_PREFIX.length), value])) : void 0;
9
+ }
10
+ function pageParamsQuery(params) {
11
+ return new URLSearchParams(
12
+ Object.entries(params || {}).map(([key, value]) => [PAGE_INPUT_PREFIX + key, value])
13
+ ).toString();
14
+ }
15
+ function decodePageInput(params = {}) {
16
+ const values = /* @__PURE__ */ Object.create(null);
17
+ const errors = [];
18
+ if (Object.keys(params).length > 64 || pageParamsQuery(params).length > 8192)
19
+ return { values, errors: ["Page input exceeds the URL size limit."] };
20
+ for (const [key, value] of Object.entries(params)) {
21
+ try {
22
+ values[key] = JSON.parse(value, (_key, item) => {
23
+ if (typeof item === "number" && (!Number.isFinite(item) || Number.isInteger(item) && !Number.isSafeInteger(item)))
24
+ throw new Error("Number cannot be represented exactly");
25
+ return item;
26
+ });
27
+ } catch {
28
+ errors.push(`${key}: expected a JSON value with finite numbers and safe integers in the URL.`);
29
+ }
30
+ }
31
+ return { values, errors };
32
+ }
33
+ function encodePageInput(values) {
34
+ if (!values || typeof values !== "object" || Array.isArray(values)) throw new Error("Page input must be an object");
35
+ const params = Object.fromEntries(
36
+ Object.entries(values).map(([key, value]) => {
37
+ const json = JSON.stringify(value, (_key, item) => {
38
+ if (item === void 0 || typeof item === "function" || typeof item === "symbol" || typeof item === "number" && (!Number.isFinite(item) || Number.isInteger(item) && !Number.isSafeInteger(item)))
39
+ throw new Error("Page input must contain JSON values");
40
+ return item;
41
+ });
42
+ return [key, json];
43
+ })
44
+ );
45
+ const decoded = decodePageInput(params);
46
+ if (decoded.errors.length) throw new Error(decoded.errors.join("; "));
47
+ return params;
48
+ }
49
+
50
+ export {
51
+ PAGE_INPUT_PREFIX,
52
+ pageParamsFromUrl,
53
+ pageParamsQuery,
54
+ decodePageInput,
55
+ encodePageInput
56
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  packHmId,
3
3
  unpackHmId
4
- } from "./chunk-7IISPGNN.mjs";
4
+ } from "./chunk-FPANFJPK.mjs";
5
5
 
6
6
  // src/document-state.ts
7
7
  async function resolveDocumentState(client, targetId) {
@@ -2,7 +2,7 @@ import {
2
2
  HM_SCHEMAS,
3
3
  HM_SCHEMA_MANIFEST,
4
4
  HM_SCHEMA_PAGES
5
- } from "./chunk-Y5XKORRF.mjs";
5
+ } from "./chunk-MLR4UDOJ.mjs";
6
6
 
7
7
  // src/schema-engine.ts
8
8
  var LIBRARY_AUTHORITY = "hyper.media";
@@ -1,3 +1,8 @@
1
+ import {
2
+ pageParamsFromUrl,
3
+ pageParamsQuery
4
+ } from "./chunk-AHQWDCHV.mjs";
5
+
1
6
  // src/hm-types.ts
2
7
  import * as z from "zod/v3";
3
8
  var BlockRangeSchema = z.object({
@@ -17,6 +22,8 @@ var unpackedHmIdSchema = z.object({
17
22
  hostname: z.string().nullable(),
18
23
  scheme: z.string().nullable(),
19
24
  latest: z.boolean().nullable().optional(),
25
+ /** JSON-encoded custom HTML page input, excluded from canonical resource identity. */
26
+ pageParams: z.record(z.string()).optional(),
20
27
  // deprecated:
21
28
  targetDocUid: z.string().nullable().optional(),
22
29
  targetDocPath: z.array(z.string()).nullable().optional()
@@ -301,6 +308,12 @@ var HMDocumentMetadataSchema = z.object({
301
308
  * in @shm/ui/agents/space-agents is the reader for this field.
302
309
  */
303
310
  spaceAgents: z.record(z.unknown()).optional(),
311
+ /** Resource type; custom HTML pages use hm://hyper.media/page. */
312
+ type: z.string().optional(),
313
+ /** UnixFS folder whose index.html runs as an isolated custom HTML page. */
314
+ html: z.string().optional(),
315
+ /** Published HM struct schema describing the page's URL input. */
316
+ inputSchema: z.string().optional(),
304
317
  layout: z.union([z.literal("Seed/Experimental/Newspaper"), z.literal("")]).optional(),
305
318
  displayPublishTime: z.string().optional(),
306
319
  displayAuthor: z.string().optional(),
@@ -1572,12 +1585,13 @@ function packBaseId(uid, path) {
1572
1585
  return `${HYPERMEDIA_SCHEME}://${uid}${restPath}`;
1573
1586
  }
1574
1587
  function packHmId(hmId) {
1575
- const { path, version, latest, blockRef, blockRange, uid } = hmId;
1588
+ const { path, version, latest, blockRef, blockRange, uid, pageParams } = hmId;
1576
1589
  if (!uid) throw new Error("uid is required");
1577
1590
  let responseUrl = packBaseId(uid, path);
1578
1591
  responseUrl += getHMQueryString({
1579
1592
  version,
1580
- latest
1593
+ latest,
1594
+ pageParams
1581
1595
  });
1582
1596
  if (blockRef) {
1583
1597
  responseUrl += `#${blockRef}${serializeBlockRange(blockRange)}`;
@@ -1587,7 +1601,8 @@ function packHmId(hmId) {
1587
1601
  function getHMQueryString({
1588
1602
  version,
1589
1603
  latest,
1590
- panel
1604
+ panel,
1605
+ pageParams
1591
1606
  }) {
1592
1607
  const query = {};
1593
1608
  if (version) {
@@ -1599,7 +1614,9 @@ function getHMQueryString({
1599
1614
  if (panel) {
1600
1615
  query.panel = panel;
1601
1616
  }
1602
- return serializeHmQueryString(query);
1617
+ const base = serializeHmQueryString(query);
1618
+ const input = pageParamsQuery(pageParams);
1619
+ return base + (input ? (base ? "&" : "?") + input : "");
1603
1620
  }
1604
1621
  function serializeBlockRange(range) {
1605
1622
  let res = "";
@@ -1701,7 +1718,8 @@ function unpackHmId(hypermediaId) {
1701
1718
  blockRange,
1702
1719
  hostname: hostname || null,
1703
1720
  latest,
1704
- scheme: parsed.scheme
1721
+ scheme: parsed.scheme,
1722
+ ...pageParamsFromUrl(hypermediaId) ? { pageParams: pageParamsFromUrl(hypermediaId) } : {}
1705
1723
  };
1706
1724
  }
1707
1725
  function codePointLength(entry) {
@@ -7,12 +7,12 @@ import {
7
7
  } from "./chunk-PJ2RFT5A.mjs";
8
8
  import {
9
9
  resolveDocumentState
10
- } from "./chunk-ICFYYWGD.mjs";
10
+ } from "./chunk-APDALLCQ.mjs";
11
11
  import {
12
12
  entityQueryPathToHmIdPath,
13
13
  packHmId,
14
14
  unpackHmId
15
- } from "./chunk-7IISPGNN.mjs";
15
+ } from "./chunk-FPANFJPK.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-7IISPGNN.mjs";
18
+ } from "./chunk-FPANFJPK.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-7IISPGNN.mjs";
3
+ } from "./chunk-FPANFJPK.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {