@truto/truto-jsonata 1.0.13 → 1.0.15

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/module.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import $hgUW1$jsonata from "jsonata";
2
- import {difference as $hgUW1$difference, groupBy as $hgUW1$groupBy, castArray as $hgUW1$castArray, keyBy as $hgUW1$keyBy, pick as $hgUW1$pick, omit as $hgUW1$omit, compact as $hgUW1$compact, join as $hgUW1$join, orderBy as $hgUW1$orderBy, find as $hgUW1$find, filter as $hgUW1$filter, values as $hgUW1$values, chunk as $hgUW1$chunk, reduce as $hgUW1$reduce, each as $hgUW1$each, get as $hgUW1$get, isEmpty as $hgUW1$isEmpty, concat as $hgUW1$concat, isEqual as $hgUW1$isEqual, flatMap as $hgUW1$flatMap, map as $hgUW1$map, set as $hgUW1$set, isString as $hgUW1$isString, flattenDeep as $hgUW1$flattenDeep, sortBy as $hgUW1$sortBy, repeat as $hgUW1$repeat, flatten as $hgUW1$flatten, reject as $hgUW1$reject, isNil as $hgUW1$isNil, isFunction as $hgUW1$isFunction, toNumber as $hgUW1$toNumber, includes as $hgUW1$includes} from "lodash-es";
2
+ import {difference as $hgUW1$difference, groupBy as $hgUW1$groupBy, castArray as $hgUW1$castArray, keyBy as $hgUW1$keyBy, pick as $hgUW1$pick, omit as $hgUW1$omit, compact as $hgUW1$compact, join as $hgUW1$join, orderBy as $hgUW1$orderBy, find as $hgUW1$find, filter as $hgUW1$filter, values as $hgUW1$values, chunk as $hgUW1$chunk, reduce as $hgUW1$reduce, each as $hgUW1$each, get as $hgUW1$get, isEmpty as $hgUW1$isEmpty, concat as $hgUW1$concat, isEqual as $hgUW1$isEqual, flatMap as $hgUW1$flatMap, map as $hgUW1$map, flattenDeep as $hgUW1$flattenDeep, set as $hgUW1$set, isString as $hgUW1$isString, sortBy as $hgUW1$sortBy, repeat as $hgUW1$repeat, flatten as $hgUW1$flatten, reject as $hgUW1$reject, isNil as $hgUW1$isNil, isFunction as $hgUW1$isFunction, toNumber as $hgUW1$toNumber, includes as $hgUW1$includes} from "lodash-es";
3
3
  import {DateTime as $hgUW1$DateTime} from "luxon";
4
4
  import {Lexer as $hgUW1$Lexer, marked as $hgUW1$marked} from "marked";
5
5
  import {diceCoefficient as $hgUW1$diceCoefficient} from "dice-coefficient";
@@ -449,6 +449,7 @@ var $1856284278f92c61$export$2e2bcd8739ae039 = $1856284278f92c61$var$convertMark
449
449
 
450
450
 
451
451
 
452
+
452
453
  const $d584c575eabd606d$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])=>{
453
454
  return (0, $hgUW1$reduce)(tokens, (acc, token)=>{
454
455
  const childTokens = token.type === "blockquote" ? (0, $hgUW1$get)(token, "tokens[0].tokens") : (0, $hgUW1$get)(token, "tokens");
@@ -510,17 +511,25 @@ const $d584c575eabd606d$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])
510
511
  return acc;
511
512
  }
512
513
  if (token.type === "code") {
514
+ const textSplitByNewLine = token.text.split("\n");
515
+ const chunksOfChunks = (0, $hgUW1$compact)((0, $hgUW1$map)(textSplitByNewLine, (chunk)=>$d584c575eabd606d$var$chunkText(chunk)));
516
+ const chunksWithNewLines = (0, $hgUW1$flattenDeep)((0, $8f5fb75395ee9099$export$2e2bcd8739ae039)((0, $hgUW1$map)(chunksOfChunks, (chunk)=>{
517
+ return (0, $hgUW1$map)(chunk, (_chunk)=>({
518
+ type: "text",
519
+ text: {
520
+ content: _chunk
521
+ }
522
+ }));
523
+ }), {
524
+ type: "text",
525
+ text: {
526
+ content: "\n\n"
527
+ }
528
+ }));
513
529
  acc.push({
514
530
  type: "code",
515
531
  code: {
516
- rich_text: [
517
- {
518
- type: "text",
519
- text: {
520
- content: token.text
521
- }
522
- }
523
- ],
532
+ rich_text: chunksWithNewLines,
524
533
  language: token.lang || "plain text"
525
534
  }
526
535
  });
@@ -623,20 +632,36 @@ const $d584c575eabd606d$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])
623
632
  const text = (0, $hgUW1$get)(token, "text");
624
633
  if (!text) return acc;
625
634
  const textToInsert = (0, $e8d3ca61f6a67481$export$2e2bcd8739ae039)(text);
626
- acc.push({
635
+ // chunk the text into 2000 character chunks, should handle emojis and multi-byte characters
636
+ const textSplitByNewLine = textToInsert.split("\n");
637
+ const chunksOfChunks = (0, $hgUW1$compact)((0, $hgUW1$map)(textSplitByNewLine, (chunk)=>$d584c575eabd606d$var$chunkText(chunk)));
638
+ const chunksWithNewLines = (0, $hgUW1$flattenDeep)((0, $8f5fb75395ee9099$export$2e2bcd8739ae039)((0, $hgUW1$map)(chunksOfChunks, (chunk)=>{
639
+ return (0, $hgUW1$map)(chunk, (_chunk)=>({
640
+ type: "text",
641
+ text: {
642
+ content: _chunk
643
+ },
644
+ ...token.type === "codespan" ? {
645
+ annotations: {
646
+ code: true
647
+ }
648
+ } : {}
649
+ }));
650
+ }), {
627
651
  type: "text",
628
652
  text: {
629
- content: textToInsert
630
- },
631
- ...token.type === "codespan" ? {
632
- annotations: {
633
- code: true
634
- }
635
- } : {}
653
+ content: "\n"
654
+ }
655
+ }));
656
+ (0, $hgUW1$each)(chunksWithNewLines, (chunk)=>{
657
+ acc.push(chunk);
636
658
  });
637
659
  return acc;
638
660
  }, acc);
639
661
  };
662
+ const $d584c575eabd606d$var$chunkText = (text, numChars = 2000)=>{
663
+ return text.match(new RegExp(`.{1,${numChars}}`, "g"));
664
+ };
640
665
  const $d584c575eabd606d$var$convertMarkdownToNotion = (text)=>{
641
666
  const tokens = (0, $hgUW1$Lexer).lex(text);
642
667
  const parsedTokens = $d584c575eabd606d$var$parseMarkedTokenToNotionRequest(tokens);