@riboseinc/anafero-cli 0.0.52 → 0.0.53

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.
package/bootstrap.js CHANGED
@@ -73900,6 +73900,47 @@ schema (${ast._tag}): ${ast}`;
73900
73900
  }
73901
73901
  });
73902
73902
 
73903
+ // ../anafero/util/graph-query.mts
73904
+ function resolveChain(relations, chain, subj_) {
73905
+ if (chain.length === 1) {
73906
+ return relations.filter((rel) => rel[1] === chain[0] && (!subj_ || rel[0] === subj_)).map((rel) => [rel[0], rel[2]]);
73907
+ } else {
73908
+ return relations.filter((rel) => rel[1] === chain[0] && (!subj_ || rel[0] === subj_)).map((rel) => resolveChain(
73909
+ relations,
73910
+ chain.slice(1),
73911
+ rel[2]
73912
+ )).flat();
73913
+ }
73914
+ }
73915
+ function getTextContent(graph, subject, partPredicate) {
73916
+ const allSubparts = (
73917
+ // TODO: subject is really only used to resolve relations,
73918
+ // maybe this can be refactored out of this function.
73919
+ resolveChain(graph, ["hasPart"], subject).flatMap(([partID, partValue]) => {
73920
+ if (!isURIString(partValue)) {
73921
+ if (partValue.startsWith("data:")) {
73922
+ return [""];
73923
+ } else if (partPredicate && !partPredicate(partValue)) {
73924
+ return [""];
73925
+ } else if (partValue.trim() === "") {
73926
+ return [""];
73927
+ } else {
73928
+ return [partValue];
73929
+ }
73930
+ } else {
73931
+ return getTextContent(graph, partValue, partPredicate);
73932
+ }
73933
+ })
73934
+ );
73935
+ return allSubparts;
73936
+ }
73937
+ var init_graph_query = __esm({
73938
+ "../anafero/util/graph-query.mts"() {
73939
+ "use strict";
73940
+ init_URI();
73941
+ }
73942
+ });
73943
+
73903
73944
  // ../anafero/index.mts
73904
73945
  var anafero_exports = {};
73905
73946
  __export(anafero_exports, {
@@ -73922,9 +73963,11 @@ schema (${ast._tag}): ${ast}`;
73922
73963
  gatherDescribedResourcesFromJsonifiedProseMirrorNode: () => gatherDescribedResourcesFromJsonifiedProseMirrorNode,
73923
73964
  gatherTextFromJsonifiedProseMirrorNode: () => gatherTextFromJsonifiedProseMirrorNode,
73924
73965
  getAllParentPaths: () => getAllParentPaths,
73966
+ getTextContent: () => getTextContent,
73925
73967
  isURIString: () => isURIString,
73926
73968
  makeDummyInMemoryCache: () => makeDummyInMemoryCache,
73927
73969
  parseModuleRef: () => parseModuleRef,
73970
+ resolveChain: () => resolveChain,
73928
73971
  stripLeadingSlash: () => stripLeadingSlash,
73929
73972
  stripTrailingSlash: () => stripTrailingSlash,
73930
73973
  titleSchema: () => titleSchema
@@ -73943,6 +73986,7 @@ schema (${ast._tag}): ${ast}`;
73943
73986
  init_moduleRef();
73944
73987
  init_cache();
73945
73988
  init_path_utils();
73989
+ init_graph_query();
73946
73990
  init_URI();
73947
73991
  }
73948
73992
  });