proskomma-core 0.10.11 → 0.10.12

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/dist/index.js CHANGED
@@ -15992,7 +15992,7 @@ var bitset = { exports: {} };
15992
15992
  var bitsetExports = bitset.exports;
15993
15993
  const BitSet = /* @__PURE__ */ getDefaultExportFromCjs(bitsetExports);
15994
15994
  const name = "proskomma-core";
15995
- const version = "0.10.11";
15995
+ const version = "0.10.12";
15996
15996
  const description$b = "A Scripture Runtime Engine";
15997
15997
  const files = [
15998
15998
  "dist"
@@ -42063,6 +42063,18 @@ const keyValueResolvers = {
42063
42063
  key: (root) => root[0],
42064
42064
  value: (root) => root[1]
42065
42065
  };
42066
+ const keyCountSchemaString = `
42067
+ """Key/Count tuple"""
42068
+ type KeyCount {
42069
+ """The key"""
42070
+ key: String!
42071
+ """The number of occurrences"""
42072
+ count: Int!
42073
+ }`;
42074
+ const keyCountResolvers = {
42075
+ key: (root) => root[0],
42076
+ count: (root) => root[1]
42077
+ };
42066
42078
  const cvSchemaString = `
42067
42079
  """A chapter-verse reference"""
42068
42080
  type cv {
@@ -44530,6 +44542,13 @@ type Sequence {
44530
44542
  """Whether to coerce the strings (toLower|toUpper|none)"""
44531
44543
  coerceCase: String
44532
44544
  ) : [String!]!
44545
+ """A list of token strings the sequence with counts"""
44546
+ uniqueTokenCounts(
44547
+ """Whether to coerce the strings (toLower|toUpper|none)"""
44548
+ coerceCase: String
44549
+ ) : [KeyCount!]!
44550
+ """A list of unique characters in the sequence with counts"""
44551
+ uniqueCharacterCounts: [KeyCount!]!
44533
44552
  """Returns true if a main sequence contains the specified tokens"""
44534
44553
  hasChars(
44535
44554
  """Token strings to be matched exactly"""
@@ -44702,6 +44721,43 @@ const sequenceResolvers = {
44702
44721
  }
44703
44722
  return Array.from(tokens2).sort();
44704
44723
  },
44724
+ uniqueCharacterCounts: (root, args, context) => {
44725
+ const characters = {};
44726
+ root.blocks.forEach(
44727
+ (b) => context.docSet.unsuccinctifyItems(b.c, { tokens: true }, null).forEach(
44728
+ (t) => {
44729
+ const chars = t[2].split("");
44730
+ for (const char of chars) {
44731
+ characters[char] ? characters[char] += 1 : characters[char] = 1;
44732
+ }
44733
+ }
44734
+ )
44735
+ );
44736
+ return Object.entries(characters).sort((a, b) => b[1] - a[1]);
44737
+ },
44738
+ uniqueTokenCounts: (root, args, context) => {
44739
+ const wordlikes = {};
44740
+ root.blocks.forEach(
44741
+ (b) => context.docSet.unsuccinctifyItems(b.c, { tokens: true }, null).forEach(
44742
+ (t) => {
44743
+ let wordlike = t[2];
44744
+ if (args.coerceCase && !["toLower", "toUpper", "none"].includes(args.coerceCase)) {
44745
+ throw new Error(
44746
+ `coerceCase, when present, must be 'toLower', 'toUpper' or 'none', not '${args.coerceCase}'`
44747
+ );
44748
+ }
44749
+ if (args.coerceCase === "toLower") {
44750
+ wordlike = wordlike.toLowerCase();
44751
+ }
44752
+ if (args.coerceCase === "toUpper") {
44753
+ wordlike = wordlike.toUpperCase();
44754
+ }
44755
+ wordlikes[wordlike] ? wordlikes[wordlike] += 1 : wordlikes[wordlike] = 1;
44756
+ }
44757
+ )
44758
+ );
44759
+ return Object.entries(wordlikes).sort((a, b) => b[1] - a[1]);
44760
+ },
44705
44761
  hasChars: (root, args, context) => {
44706
44762
  if (root.type !== "main") {
44707
44763
  throw new Error(`Only available for the main sequence, not ${root.type}`);
@@ -49905,6 +49961,7 @@ const typeDefs = `
49905
49961
  ${querySchemaString}
49906
49962
  ${mutationsSchemaString}
49907
49963
  ${keyValueSchemaString}
49964
+ ${keyCountSchemaString}
49908
49965
  ${cvSchemaString}
49909
49966
  ${idPartsSchemaString}
49910
49967
  ${inputAttSpecSchemaString}
@@ -49946,6 +50003,7 @@ const resolvers = {
49946
50003
  Mutation: mutationsResolvers,
49947
50004
  Query: queryResolvers,
49948
50005
  KeyValue: keyValueResolvers,
50006
+ KeyCount: keyCountResolvers,
49949
50007
  cv: cvResolvers,
49950
50008
  idParts: idPartsResolvers,
49951
50009
  Item: itemResolvers,
package/dist/index.mjs CHANGED
@@ -15990,7 +15990,7 @@ var bitset = { exports: {} };
15990
15990
  var bitsetExports = bitset.exports;
15991
15991
  const BitSet = /* @__PURE__ */ getDefaultExportFromCjs(bitsetExports);
15992
15992
  const name = "proskomma-core";
15993
- const version = "0.10.11";
15993
+ const version = "0.10.12";
15994
15994
  const description$b = "A Scripture Runtime Engine";
15995
15995
  const files = [
15996
15996
  "dist"
@@ -42061,6 +42061,18 @@ const keyValueResolvers = {
42061
42061
  key: (root) => root[0],
42062
42062
  value: (root) => root[1]
42063
42063
  };
42064
+ const keyCountSchemaString = `
42065
+ """Key/Count tuple"""
42066
+ type KeyCount {
42067
+ """The key"""
42068
+ key: String!
42069
+ """The number of occurrences"""
42070
+ count: Int!
42071
+ }`;
42072
+ const keyCountResolvers = {
42073
+ key: (root) => root[0],
42074
+ count: (root) => root[1]
42075
+ };
42064
42076
  const cvSchemaString = `
42065
42077
  """A chapter-verse reference"""
42066
42078
  type cv {
@@ -44528,6 +44540,13 @@ type Sequence {
44528
44540
  """Whether to coerce the strings (toLower|toUpper|none)"""
44529
44541
  coerceCase: String
44530
44542
  ) : [String!]!
44543
+ """A list of token strings the sequence with counts"""
44544
+ uniqueTokenCounts(
44545
+ """Whether to coerce the strings (toLower|toUpper|none)"""
44546
+ coerceCase: String
44547
+ ) : [KeyCount!]!
44548
+ """A list of unique characters in the sequence with counts"""
44549
+ uniqueCharacterCounts: [KeyCount!]!
44531
44550
  """Returns true if a main sequence contains the specified tokens"""
44532
44551
  hasChars(
44533
44552
  """Token strings to be matched exactly"""
@@ -44700,6 +44719,43 @@ const sequenceResolvers = {
44700
44719
  }
44701
44720
  return Array.from(tokens2).sort();
44702
44721
  },
44722
+ uniqueCharacterCounts: (root, args, context) => {
44723
+ const characters = {};
44724
+ root.blocks.forEach(
44725
+ (b) => context.docSet.unsuccinctifyItems(b.c, { tokens: true }, null).forEach(
44726
+ (t) => {
44727
+ const chars = t[2].split("");
44728
+ for (const char of chars) {
44729
+ characters[char] ? characters[char] += 1 : characters[char] = 1;
44730
+ }
44731
+ }
44732
+ )
44733
+ );
44734
+ return Object.entries(characters).sort((a, b) => b[1] - a[1]);
44735
+ },
44736
+ uniqueTokenCounts: (root, args, context) => {
44737
+ const wordlikes = {};
44738
+ root.blocks.forEach(
44739
+ (b) => context.docSet.unsuccinctifyItems(b.c, { tokens: true }, null).forEach(
44740
+ (t) => {
44741
+ let wordlike = t[2];
44742
+ if (args.coerceCase && !["toLower", "toUpper", "none"].includes(args.coerceCase)) {
44743
+ throw new Error(
44744
+ `coerceCase, when present, must be 'toLower', 'toUpper' or 'none', not '${args.coerceCase}'`
44745
+ );
44746
+ }
44747
+ if (args.coerceCase === "toLower") {
44748
+ wordlike = wordlike.toLowerCase();
44749
+ }
44750
+ if (args.coerceCase === "toUpper") {
44751
+ wordlike = wordlike.toUpperCase();
44752
+ }
44753
+ wordlikes[wordlike] ? wordlikes[wordlike] += 1 : wordlikes[wordlike] = 1;
44754
+ }
44755
+ )
44756
+ );
44757
+ return Object.entries(wordlikes).sort((a, b) => b[1] - a[1]);
44758
+ },
44703
44759
  hasChars: (root, args, context) => {
44704
44760
  if (root.type !== "main") {
44705
44761
  throw new Error(`Only available for the main sequence, not ${root.type}`);
@@ -49903,6 +49959,7 @@ const typeDefs = `
49903
49959
  ${querySchemaString}
49904
49960
  ${mutationsSchemaString}
49905
49961
  ${keyValueSchemaString}
49962
+ ${keyCountSchemaString}
49906
49963
  ${cvSchemaString}
49907
49964
  ${idPartsSchemaString}
49908
49965
  ${inputAttSpecSchemaString}
@@ -49944,6 +50001,7 @@ const resolvers = {
49944
50001
  Mutation: mutationsResolvers,
49945
50002
  Query: queryResolvers,
49946
50003
  KeyValue: keyValueResolvers,
50004
+ KeyCount: keyCountResolvers,
49947
50005
  cv: cvResolvers,
49948
50006
  idParts: idPartsResolvers,
49949
50007
  Item: itemResolvers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proskomma-core",
3
- "version": "0.10.11",
3
+ "version": "0.10.12",
4
4
  "description": "A Scripture Runtime Engine",
5
5
  "files": [
6
6
  "dist"