@seed-hypermedia/client 0.0.101 → 0.0.102

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 (34) hide show
  1. package/dist/auto-link.mjs +3 -3
  2. package/dist/blocks-to-markdown.mjs +2 -2
  3. package/dist/capability.mjs +2 -2
  4. package/dist/{chunk-KUCHTHLG.mjs → chunk-4MZHSZFQ.mjs} +7 -5
  5. package/dist/{chunk-QRXNROVO.mjs → chunk-DQR4RPYC.mjs} +5 -1
  6. package/dist/{chunk-GCBKFXKL.mjs → chunk-EZ5DM5TI.mjs} +1 -1
  7. package/dist/{chunk-PO3UBPBJ.mjs → chunk-G6AYTCLG.mjs} +1 -1
  8. package/dist/{chunk-7DXNZGR5.mjs → chunk-GIKXPGFZ.mjs} +1 -1
  9. package/dist/{chunk-OAIUNL5V.mjs → chunk-KDI4WJKM.mjs} +1 -1
  10. package/dist/{chunk-5ECP2AA6.mjs → chunk-MHICVQJI.mjs} +3 -3
  11. package/dist/{chunk-GJ3L3MYM.mjs → chunk-NSNLRZ3X.mjs} +1 -1
  12. package/dist/{chunk-VPEN5FUU.mjs → chunk-S4XBFD3S.mjs} +1 -1
  13. package/dist/{chunk-RBX7IGCN.mjs → chunk-SKIKB2TP.mjs} +29 -1
  14. package/dist/{chunk-TQLNIME2.mjs → chunk-TLOQU4IT.mjs} +2 -2
  15. package/dist/{chunk-YLWLQUUZ.mjs → chunk-UPYQNWW5.mjs} +4 -1
  16. package/dist/{chunk-TJFFZMRI.mjs → chunk-V5XCZMPG.mjs} +1 -1
  17. package/dist/{chunk-AVFMKA27.mjs → chunk-Z5BSKGOF.mjs} +1 -1
  18. package/dist/client.mjs +2 -2
  19. package/dist/comment.mjs +2 -2
  20. package/dist/document-state.mjs +2 -2
  21. package/dist/editor-types.d.ts +1 -0
  22. package/dist/editorblock-to-hmblock.mjs +2 -2
  23. package/dist/hm-resolver.mjs +2 -2
  24. package/dist/hm-types.d.ts +293 -0
  25. package/dist/hm-types.mjs +7 -1
  26. package/dist/hmblock-to-editorblock.mjs +2 -2
  27. package/dist/index.mjs +13 -13
  28. package/dist/pdf-to-blocks.mjs +3 -3
  29. package/dist/resource-read.mjs +4 -4
  30. package/dist/schema-resolve.mjs +2 -2
  31. package/dist/schema-subtypes.mjs +2 -2
  32. package/dist/tei-to-blocks.mjs +2 -2
  33. package/dist/unicode.mjs +1 -1
  34. package/package.json +1 -1
@@ -4,13 +4,13 @@ import {
4
4
  documentContainsLinkToChild,
5
5
  documentHasSelfQuery,
6
6
  shouldAutoLinkParent
7
- } from "./chunk-TQLNIME2.mjs";
7
+ } from "./chunk-TLOQU4IT.mjs";
8
8
  import "./chunk-O5MHN2EO.mjs";
9
9
  import "./chunk-PJ2RFT5A.mjs";
10
- import "./chunk-AVFMKA27.mjs";
10
+ import "./chunk-Z5BSKGOF.mjs";
11
11
  import "./chunk-LVAHHQIK.mjs";
12
12
  import "./chunk-DR3HJ6BV.mjs";
13
- import "./chunk-RBX7IGCN.mjs";
13
+ import "./chunk-SKIKB2TP.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-YLWLQUUZ.mjs";
11
- import "./chunk-RBX7IGCN.mjs";
10
+ } from "./chunk-UPYQNWW5.mjs";
11
+ import "./chunk-SKIKB2TP.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-OAIUNL5V.mjs";
4
+ } from "./chunk-KDI4WJKM.mjs";
5
5
  import "./chunk-LVAHHQIK.mjs";
6
6
  import "./chunk-NBCHK76Q.mjs";
7
7
  import "./chunk-DR3HJ6BV.mjs";
8
- import "./chunk-RBX7IGCN.mjs";
8
+ import "./chunk-SKIKB2TP.mjs";
9
9
  import "./chunk-3TPCJCVO.mjs";
10
10
  import "./chunk-7P6ASYW6.mjs";
11
11
  export {
@@ -1,6 +1,7 @@
1
1
  import {
2
+ getSupportedHMQueryFilters,
2
3
  isSurrogate
3
- } from "./chunk-RBX7IGCN.mjs";
4
+ } from "./chunk-SKIKB2TP.mjs";
4
5
 
5
6
  // src/hmblock-to-editorblock.ts
6
7
  function toEditorBlockType(hmBlockType) {
@@ -67,7 +68,7 @@ function hmBlocksToEditorContent(blocks, opts = { level: 1 }) {
67
68
  }).filter((block) => block !== null);
68
69
  }
69
70
  function hmBlockToEditorBlock(block) {
70
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
71
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
71
72
  const blockType = toEditorBlockType(block.type);
72
73
  if (blockType === "unknown") {
73
74
  return {
@@ -162,9 +163,10 @@ function hmBlockToEditorBlock(block) {
162
163
  queryProps.columnCount = String(((_f = block.attributes) == null ? void 0 : _f.columnCount) || "");
163
164
  queryProps.queryIncludes = JSON.stringify(((_h = (_g = block.attributes) == null ? void 0 : _g.query) == null ? void 0 : _h.includes) || []);
164
165
  queryProps.querySort = JSON.stringify(((_j = (_i = block.attributes) == null ? void 0 : _i.query) == null ? void 0 : _j.sort) || {});
165
- queryProps.banner = ((_k = block.attributes) == null ? void 0 : _k.banner) ? "true" : "false";
166
- queryProps.queryLimit = String(((_m = (_l = block.attributes) == null ? void 0 : _l.query) == null ? void 0 : _m.limit) || "");
167
- if ((_n = block.attributes) == null ? void 0 : _n.table) queryProps.tableConfig = JSON.stringify(block.attributes.table);
166
+ queryProps.queryFilters = JSON.stringify(getSupportedHMQueryFilters((_l = (_k = block.attributes) == null ? void 0 : _k.query) == null ? void 0 : _l.filters));
167
+ queryProps.banner = ((_m = block.attributes) == null ? void 0 : _m.banner) ? "true" : "false";
168
+ queryProps.queryLimit = String(((_o = (_n = block.attributes) == null ? void 0 : _n.query) == null ? void 0 : _o.limit) || "");
169
+ if ((_p = block.attributes) == null ? void 0 : _p.table) queryProps.tableConfig = JSON.stringify(block.attributes.table);
168
170
  }
169
171
  const blockText = block.text || "";
170
172
  const leaves = out.content;
@@ -5,8 +5,9 @@ import {
5
5
  HMBlockButtonAlignmentSchema,
6
6
  HMBlockSchema,
7
7
  codePointLength,
8
+ parseHMQueryFiltersJSON,
8
9
  toNumber
9
- } from "./chunk-RBX7IGCN.mjs";
10
+ } from "./chunk-SKIKB2TP.mjs";
10
11
 
11
12
  // src/editorblock-to-hmblock.ts
12
13
  function toHMBlockType(editorBlockType) {
@@ -248,6 +249,9 @@ function editorBlockToHMBlock(editorBlock) {
248
249
  };
249
250
  if (editorBlock.props.queryIncludes) query.includes = JSON.parse(editorBlock.props.queryIncludes);
250
251
  if (editorBlock.props.querySort) query.sort = JSON.parse(editorBlock.props.querySort);
252
+ if (editorBlock.props.queryFilters) {
253
+ query.filters = parseHMQueryFiltersJSON(editorBlock.props.queryFilters);
254
+ }
251
255
  if (editorBlock.props.queryLimit) query.limit = Number(editorBlock.props.queryLimit);
252
256
  blockQuery.attributes.query = query;
253
257
  blockQuery.attributes.banner = editorBlock.props.banner == "true";
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  hmIdPathToEntityQueryPath,
11
11
  packHmId
12
- } from "./chunk-RBX7IGCN.mjs";
12
+ } from "./chunk-SKIKB2TP.mjs";
13
13
 
14
14
  // src/comment.ts
15
15
  import { decode as cborDecode, encode as cborEncode } from "@ipld/dag-cbor";
@@ -15,7 +15,7 @@ import {
15
15
  HMActionSchema,
16
16
  HMRequestSchema,
17
17
  packHmId
18
- } from "./chunk-RBX7IGCN.mjs";
18
+ } from "./chunk-SKIKB2TP.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-RBX7IGCN.mjs";
3
+ } from "./chunk-SKIKB2TP.mjs";
4
4
 
5
5
  // src/tei-to-blocks.ts
6
6
  function generateBlockId() {
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  entityQueryPathToHmIdPath,
9
9
  packBaseId
10
- } from "./chunk-RBX7IGCN.mjs";
10
+ } from "./chunk-SKIKB2TP.mjs";
11
11
 
12
12
  // src/capability.ts
13
13
  import { base58btc } from "multiformats/bases/base58";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  resolveId
3
- } from "./chunk-TJFFZMRI.mjs";
3
+ } from "./chunk-V5XCZMPG.mjs";
4
4
  import {
5
5
  createSeedClient
6
- } from "./chunk-PO3UBPBJ.mjs";
6
+ } from "./chunk-G6AYTCLG.mjs";
7
7
  import {
8
8
  unpackHmId
9
- } from "./chunk-RBX7IGCN.mjs";
9
+ } from "./chunk-SKIKB2TP.mjs";
10
10
 
11
11
  // src/resource-read.ts
12
12
  async function resolveIdWithClient(rawId, options = {}) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  teiToBlocks
3
- } from "./chunk-7DXNZGR5.mjs";
3
+ } from "./chunk-GIKXPGFZ.mjs";
4
4
  import {
5
5
  embeddedPdfToBlocks
6
6
  } from "./chunk-2FJBS3V7.mjs";
@@ -20,7 +20,7 @@ import {
20
20
  import {
21
21
  packHmId,
22
22
  unpackHmId
23
- } from "./chunk-RBX7IGCN.mjs";
23
+ } from "./chunk-SKIKB2TP.mjs";
24
24
 
25
25
  // src/schema-resolve.ts
26
26
  var DAG_CBOR_CODE = 113;
@@ -507,13 +507,38 @@ var HMQuerySortSchema = z.object({
507
507
  term: z.string().optional(),
508
508
  reverse: z.boolean().optional()
509
509
  }).transform(normalizeQuerySortEntry);
510
+ var HMQueryFilterSchema = z.discriminatedUnion("type", [
511
+ z.object({
512
+ type: z.literal("Author"),
513
+ uid: z.string()
514
+ })
515
+ ]);
516
+ function getSupportedHMQueryFilters(val) {
517
+ if (!Array.isArray(val)) return [];
518
+ return val.filter(
519
+ (filter) => filter !== null && typeof filter === "object" && filter.type === "Author" && typeof filter.uid === "string"
520
+ );
521
+ }
522
+ function parseHMQueryFiltersJSON(rawFilters) {
523
+ if (!rawFilters) return [];
524
+ try {
525
+ return getSupportedHMQueryFilters(JSON.parse(rawFilters));
526
+ } catch {
527
+ return [];
528
+ }
529
+ }
530
+ function removeUnsupportedQueryFilters(val) {
531
+ if (val === void 0) return void 0;
532
+ return getSupportedHMQueryFilters(val);
533
+ }
510
534
  var HMQuerySchema = z.object({
511
535
  includes: z.array(HMQueryInclusionSchema),
512
536
  sort: z.array(HMQuerySortSchema).optional(),
513
537
  limit: z.preprocess(
514
538
  (val) => val === "" || val === null || val === void 0 ? void 0 : val,
515
539
  z.coerce.number().optional()
516
- )
540
+ ),
541
+ filters: z.preprocess(removeUnsupportedQueryFilters, z.array(HMQueryFilterSchema).optional())
517
542
  });
518
543
  var HMBlockTableSchema = z.object({
519
544
  type: z.literal("Table"),
@@ -1740,6 +1765,9 @@ export {
1740
1765
  normalizeQuerySortEntry,
1741
1766
  normalizeQuerySort,
1742
1767
  HMQuerySortSchema,
1768
+ HMQueryFilterSchema,
1769
+ getSupportedHMQueryFilters,
1770
+ parseHMQueryFiltersJSON,
1743
1771
  HMQuerySchema,
1744
1772
  HMBlockTableSchema,
1745
1773
  HMBlockTableRowSchema,
@@ -7,12 +7,12 @@ import {
7
7
  } from "./chunk-PJ2RFT5A.mjs";
8
8
  import {
9
9
  resolveDocumentState
10
- } from "./chunk-AVFMKA27.mjs";
10
+ } from "./chunk-Z5BSKGOF.mjs";
11
11
  import {
12
12
  entityQueryPathToHmIdPath,
13
13
  packHmId,
14
14
  unpackHmId
15
- } from "./chunk-RBX7IGCN.mjs";
15
+ } from "./chunk-SKIKB2TP.mjs";
16
16
 
17
17
  // src/auto-link.ts
18
18
  import { CID } from "multiformats/cid";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  normalizeQuerySort,
3
3
  unpackHmId
4
- } from "./chunk-RBX7IGCN.mjs";
4
+ } from "./chunk-SKIKB2TP.mjs";
5
5
 
6
6
  // src/blocks-to-markdown.ts
7
7
  import { stringify as stringifyYaml } from "yaml";
@@ -618,6 +618,7 @@ async function resolveQuery(block, depth, ctx) {
618
618
  const queryConfig = attrs == null ? void 0 : attrs.query;
619
619
  let includes;
620
620
  let sort;
621
+ let filters;
621
622
  let limit;
622
623
  if (queryConfig == null ? void 0 : queryConfig.includes) {
623
624
  if (!((_a = queryConfig.includes[0]) == null ? void 0 : _a.space)) return ind + "<!-- Query: no space specified -->";
@@ -627,6 +628,7 @@ async function resolveQuery(block, depth, ctx) {
627
628
  mode: inc.mode || "Children"
628
629
  }));
629
630
  sort = normalizeQuerySort(queryConfig.sort);
631
+ filters = queryConfig.filters;
630
632
  limit = queryConfig.limit;
631
633
  } else {
632
634
  const space = (attrs == null ? void 0 : attrs.space) || "";
@@ -643,6 +645,7 @@ async function resolveQuery(block, depth, ctx) {
643
645
  const results = await ctx.client.request("Query", {
644
646
  includes,
645
647
  sort: (sort == null ? void 0 : sort.length) ? sort : [{ term: "updated", reverse: true }],
648
+ filters,
646
649
  limit: limit || 10
647
650
  });
648
651
  if (!((_b = results == null ? void 0 : results.results) == null ? void 0 : _b.length)) return ind + "<!-- Query: no results -->";
@@ -2,7 +2,7 @@ import {
2
2
  entityQueryPathToHmIdPath,
3
3
  parseFragment,
4
4
  unpackHmId
5
- } from "./chunk-RBX7IGCN.mjs";
5
+ } from "./chunk-SKIKB2TP.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-RBX7IGCN.mjs";
4
+ } from "./chunk-SKIKB2TP.mjs";
5
5
 
6
6
  // src/document-state.ts
7
7
  async function resolveDocumentState(client, targetId) {
package/dist/client.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createSeedClient,
3
3
  deserializeQueryString
4
- } from "./chunk-PO3UBPBJ.mjs";
4
+ } from "./chunk-G6AYTCLG.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-RBX7IGCN.mjs";
10
+ import "./chunk-SKIKB2TP.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-GCBKFXKL.mjs";
7
+ } from "./chunk-EZ5DM5TI.mjs";
8
8
  import "./chunk-JKKS35IS.mjs";
9
9
  import "./chunk-LVAHHQIK.mjs";
10
10
  import "./chunk-DR3HJ6BV.mjs";
11
- import "./chunk-RBX7IGCN.mjs";
11
+ import "./chunk-SKIKB2TP.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-AVFMKA27.mjs";
8
- import "./chunk-RBX7IGCN.mjs";
7
+ } from "./chunk-Z5BSKGOF.mjs";
8
+ import "./chunk-SKIKB2TP.mjs";
9
9
  import "./chunk-7P6ASYW6.mjs";
10
10
  export {
11
11
  describeRedirect,
@@ -110,6 +110,7 @@ export type EditorQueryBlock = EditorBaseBlock & {
110
110
  queryLimit?: string;
111
111
  queryIncludes?: string;
112
112
  querySort?: string;
113
+ queryFilters?: string;
113
114
  banner?: 'true' | 'false';
114
115
  defaultOpen?: 'true' | 'false';
115
116
  tableConfig?: string;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  editorBlockToHMBlock,
3
3
  editorBlocksToHMBlockNodes
4
- } from "./chunk-QRXNROVO.mjs";
4
+ } from "./chunk-DQR4RPYC.mjs";
5
5
  import "./chunk-JKKS35IS.mjs";
6
- import "./chunk-RBX7IGCN.mjs";
6
+ import "./chunk-SKIKB2TP.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-TJFFZMRI.mjs";
5
- import "./chunk-RBX7IGCN.mjs";
4
+ } from "./chunk-V5XCZMPG.mjs";
5
+ import "./chunk-SKIKB2TP.mjs";
6
6
  import "./chunk-7P6ASYW6.mjs";
7
7
  export {
8
8
  resolveHypermediaUrl,