@truto/truto-jsonata 1.0.25 → 1.0.27
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/main.cjs +111 -111
- package/dist/main.cjs.map +1 -1
- package/dist/module.js +15 -15
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/main.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var $dxT2C$jsonata = require("jsonata");
|
|
2
|
-
var $dxT2C$
|
|
2
|
+
var $dxT2C$lodash = require("lodash");
|
|
3
3
|
var $dxT2C$mixmarkiodomino = require("@mixmark-io/domino");
|
|
4
4
|
var $dxT2C$trutoturndownplugingfm = require("@truto/turndown-plugin-gfm");
|
|
5
5
|
var $dxT2C$turndown = require("turndown");
|
|
@@ -91,7 +91,7 @@ var $0183648cc15cbf3c$export$2e2bcd8739ae039 = $0183648cc15cbf3c$var$base64ToBlo
|
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
function $5e0c34680d37ee90$var$blob(content, options) {
|
|
94
|
-
return new Blob((0, $dxT2C$
|
|
94
|
+
return new Blob((0, $dxT2C$lodash.castArray)(content || ""), options);
|
|
95
95
|
}
|
|
96
96
|
var $5e0c34680d37ee90$export$2e2bcd8739ae039 = $5e0c34680d37ee90$var$blob;
|
|
97
97
|
|
|
@@ -114,7 +114,7 @@ $ca838bf406ad8d65$exports = JSON.parse('{"AED":{"code":"AED","number":"784","dig
|
|
|
114
114
|
|
|
115
115
|
|
|
116
116
|
function $9c8dd912df011d47$var$convertCurrencyFromSubunit(arg, currencyCode) {
|
|
117
|
-
if ((0, $dxT2C$
|
|
117
|
+
if ((0, $dxT2C$lodash.isNil)(arg)) return arg;
|
|
118
118
|
// @ts-ignore
|
|
119
119
|
if ((0, (/*@__PURE__*/$parcel$interopDefault($ca838bf406ad8d65$exports)))[currencyCode]) {
|
|
120
120
|
const amount = parseFloat(arg);
|
|
@@ -130,7 +130,7 @@ var $9c8dd912df011d47$export$2e2bcd8739ae039 = $9c8dd912df011d47$var$convertCurr
|
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
function $17f6ad04ec182cbf$var$convertCurrencyToSubunit(arg, currencyCode) {
|
|
133
|
-
if ((0, $dxT2C$
|
|
133
|
+
if ((0, $dxT2C$lodash.isNil)(arg)) return arg;
|
|
134
134
|
// @ts-ignore
|
|
135
135
|
if ((0, (/*@__PURE__*/$parcel$interopDefault($ca838bf406ad8d65$exports)))[currencyCode]) {
|
|
136
136
|
const amount = parseFloat(arg);
|
|
@@ -158,20 +158,6 @@ var $59b0e4ac45b59e5b$export$2e2bcd8739ae039 = $59b0e4ac45b59e5b$var$convertHtml
|
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
const $233848446ca33fe6$var$insertBetween = (arr, value)=>{
|
|
163
|
-
return (0, $dxT2C$lodashes.flatMap)(arr, (item, index)=>{
|
|
164
|
-
return index === arr.length - 1 ? [
|
|
165
|
-
item
|
|
166
|
-
] : [
|
|
167
|
-
item,
|
|
168
|
-
...(0, $dxT2C$lodashes.castArray)(value)
|
|
169
|
-
];
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
var $233848446ca33fe6$export$2e2bcd8739ae039 = $233848446ca33fe6$var$insertBetween;
|
|
173
|
-
|
|
174
|
-
|
|
175
161
|
function $5a7cb266718aeaae$var$decodeHtmlEntities(encodedString) {
|
|
176
162
|
const htmlEntities = {
|
|
177
163
|
"&": "&",
|
|
@@ -189,6 +175,20 @@ function $5a7cb266718aeaae$var$decodeHtmlEntities(encodedString) {
|
|
|
189
175
|
var $5a7cb266718aeaae$export$2e2bcd8739ae039 = $5a7cb266718aeaae$var$decodeHtmlEntities;
|
|
190
176
|
|
|
191
177
|
|
|
178
|
+
|
|
179
|
+
const $233848446ca33fe6$var$insertBetween = (arr, value)=>{
|
|
180
|
+
return (0, $dxT2C$lodash.flatMap)(arr, (item, index)=>{
|
|
181
|
+
return index === arr.length - 1 ? [
|
|
182
|
+
item
|
|
183
|
+
] : [
|
|
184
|
+
item,
|
|
185
|
+
...(0, $dxT2C$lodash.castArray)(value)
|
|
186
|
+
];
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
var $233848446ca33fe6$export$2e2bcd8739ae039 = $233848446ca33fe6$var$insertBetween;
|
|
190
|
+
|
|
191
|
+
|
|
192
192
|
const $90c566adb85cb52e$var$parseMarkedTokenToGoogleDocsRequest = (tokens, acc = {
|
|
193
193
|
counter: 1,
|
|
194
194
|
offset: 0,
|
|
@@ -197,7 +197,7 @@ const $90c566adb85cb52e$var$parseMarkedTokenToGoogleDocsRequest = (tokens, acc =
|
|
|
197
197
|
}, context = {
|
|
198
198
|
level: 0
|
|
199
199
|
})=>{
|
|
200
|
-
return (0, $dxT2C$
|
|
200
|
+
return (0, $dxT2C$lodash.reduce)(tokens, (acc, token)=>{
|
|
201
201
|
if (token.type === "hr") {
|
|
202
202
|
acc.inserts.push({
|
|
203
203
|
insertText: {
|
|
@@ -246,11 +246,11 @@ const $90c566adb85cb52e$var$parseMarkedTokenToGoogleDocsRequest = (tokens, acc =
|
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
248
|
acc.counter += 4;
|
|
249
|
-
(0, $dxT2C$
|
|
249
|
+
(0, $dxT2C$lodash.each)([
|
|
250
250
|
token.header,
|
|
251
251
|
...token.rows
|
|
252
252
|
], (rowItems, index, arr)=>{
|
|
253
|
-
(0, $dxT2C$
|
|
253
|
+
(0, $dxT2C$lodash.each)(rowItems, (item)=>{
|
|
254
254
|
$90c566adb85cb52e$var$parseMarkedTokenToGoogleDocsRequest([
|
|
255
255
|
item
|
|
256
256
|
], acc, context);
|
|
@@ -270,8 +270,8 @@ const $90c566adb85cb52e$var$parseMarkedTokenToGoogleDocsRequest = (tokens, acc =
|
|
|
270
270
|
acc.counter += 1;
|
|
271
271
|
return acc;
|
|
272
272
|
}
|
|
273
|
-
const childTokens = (0, $dxT2C$
|
|
274
|
-
if (!(0, $dxT2C$
|
|
273
|
+
const childTokens = (0, $dxT2C$lodash.get)(token, "tokens");
|
|
274
|
+
if (!(0, $dxT2C$lodash.isEmpty)(childTokens)) {
|
|
275
275
|
const start = acc.counter;
|
|
276
276
|
if (token.type === "list_item") {
|
|
277
277
|
if (context.level > 1) {
|
|
@@ -367,8 +367,8 @@ const $90c566adb85cb52e$var$parseMarkedTokenToGoogleDocsRequest = (tokens, acc =
|
|
|
367
367
|
});
|
|
368
368
|
return acc;
|
|
369
369
|
}
|
|
370
|
-
const childItems = (0, $dxT2C$
|
|
371
|
-
if (!(0, $dxT2C$
|
|
370
|
+
const childItems = (0, $dxT2C$lodash.get)(token, "items");
|
|
371
|
+
if (!(0, $dxT2C$lodash.isEmpty)(childItems)) {
|
|
372
372
|
const start = acc.counter;
|
|
373
373
|
$90c566adb85cb52e$var$parseMarkedTokenToGoogleDocsRequest((0, $233848446ca33fe6$export$2e2bcd8739ae039)(childItems, [
|
|
374
374
|
{
|
|
@@ -379,7 +379,7 @@ const $90c566adb85cb52e$var$parseMarkedTokenToGoogleDocsRequest = (tokens, acc =
|
|
|
379
379
|
level: context.level + 1
|
|
380
380
|
});
|
|
381
381
|
const end = acc.counter;
|
|
382
|
-
if (!context.level && token.type === "list") acc.formats = (0, $dxT2C$
|
|
382
|
+
if (!context.level && token.type === "list") acc.formats = (0, $dxT2C$lodash.concat)({
|
|
383
383
|
createParagraphBullets: {
|
|
384
384
|
range: {
|
|
385
385
|
startIndex: start,
|
|
@@ -390,7 +390,7 @@ const $90c566adb85cb52e$var$parseMarkedTokenToGoogleDocsRequest = (tokens, acc =
|
|
|
390
390
|
}, acc.formats);
|
|
391
391
|
return acc;
|
|
392
392
|
}
|
|
393
|
-
const text = (0, $dxT2C$
|
|
393
|
+
const text = (0, $dxT2C$lodash.get)(token, "text");
|
|
394
394
|
if (!text) return acc;
|
|
395
395
|
const textToInsert = (0, $5a7cb266718aeaae$export$2e2bcd8739ae039)(text);
|
|
396
396
|
acc.inserts.push({
|
|
@@ -414,13 +414,13 @@ const $90c566adb85cb52e$var$convertMarkdownToGoogleDocs = (text, currentCounter
|
|
|
414
414
|
offset: 0
|
|
415
415
|
});
|
|
416
416
|
const formats = parsedTokens.formats;
|
|
417
|
-
const mergedFormats = (0, $dxT2C$
|
|
418
|
-
const range = (0, $dxT2C$
|
|
417
|
+
const mergedFormats = (0, $dxT2C$lodash.reduce)(formats, (acc, format)=>{
|
|
418
|
+
const range = (0, $dxT2C$lodash.get)(format, "updateTextStyle.range");
|
|
419
419
|
if (!range) acc.push(format);
|
|
420
420
|
else {
|
|
421
|
-
const existingFormat = (0, $dxT2C$
|
|
422
|
-
const r = (0, $dxT2C$
|
|
423
|
-
return (0, $dxT2C$
|
|
421
|
+
const existingFormat = (0, $dxT2C$lodash.find)(acc, (f)=>{
|
|
422
|
+
const r = (0, $dxT2C$lodash.get)(f, "updateTextStyle.range");
|
|
423
|
+
return (0, $dxT2C$lodash.isEqual)(r, range);
|
|
424
424
|
});
|
|
425
425
|
if (existingFormat) existingFormat.updateTextStyle.textStyle = {
|
|
426
426
|
...existingFormat.updateTextStyle.textStyle,
|
|
@@ -452,8 +452,8 @@ var $2c639152271462a6$export$2e2bcd8739ae039 = $2c639152271462a6$var$convertMark
|
|
|
452
452
|
|
|
453
453
|
|
|
454
454
|
const $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])=>{
|
|
455
|
-
return (0, $dxT2C$
|
|
456
|
-
const childTokens = token.type === "blockquote" ? (0, $dxT2C$
|
|
455
|
+
return (0, $dxT2C$lodash.reduce)(tokens, (acc, token)=>{
|
|
456
|
+
const childTokens = token.type === "blockquote" ? (0, $dxT2C$lodash.get)(token, "tokens[0].tokens") : (0, $dxT2C$lodash.get)(token, "tokens");
|
|
457
457
|
let childData = [];
|
|
458
458
|
if (childTokens) childData = $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest(childTokens);
|
|
459
459
|
if (token.type === "hr") {
|
|
@@ -492,14 +492,14 @@ const $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])
|
|
|
492
492
|
return acc;
|
|
493
493
|
}
|
|
494
494
|
if (token.type === "paragraph") {
|
|
495
|
-
const groupedChildData = (0, $dxT2C$
|
|
496
|
-
if (!(0, $dxT2C$
|
|
495
|
+
const groupedChildData = (0, $dxT2C$lodash.groupBy)(childData, (x)=>x.type === "image" ? "image" : "other");
|
|
496
|
+
if (!(0, $dxT2C$lodash.isEmpty)(groupedChildData.other)) acc.push({
|
|
497
497
|
type: "paragraph",
|
|
498
498
|
paragraph: {
|
|
499
499
|
rich_text: groupedChildData.other
|
|
500
500
|
}
|
|
501
501
|
});
|
|
502
|
-
if (!(0, $dxT2C$
|
|
502
|
+
if (!(0, $dxT2C$lodash.isEmpty)(groupedChildData.image)) acc = (0, $dxT2C$lodash.concat)(acc, groupedChildData.image);
|
|
503
503
|
return acc;
|
|
504
504
|
}
|
|
505
505
|
if (token.type === "heading") {
|
|
@@ -513,9 +513,9 @@ const $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])
|
|
|
513
513
|
}
|
|
514
514
|
if (token.type === "code") {
|
|
515
515
|
const textSplitByNewLine = token.text.split("\n");
|
|
516
|
-
const chunksOfChunks = (0, $dxT2C$
|
|
517
|
-
const chunksWithNewLines = (0, $dxT2C$
|
|
518
|
-
return (0, $dxT2C$
|
|
516
|
+
const chunksOfChunks = (0, $dxT2C$lodash.compact)((0, $dxT2C$lodash.map)(textSplitByNewLine, (chunk)=>$bc8e7b2fdb012b3a$var$chunkText(chunk)));
|
|
517
|
+
const chunksWithNewLines = (0, $dxT2C$lodash.flattenDeep)((0, $233848446ca33fe6$export$2e2bcd8739ae039)((0, $dxT2C$lodash.map)(chunksOfChunks, (chunk)=>{
|
|
518
|
+
return (0, $dxT2C$lodash.map)(chunk, (_chunk)=>({
|
|
519
519
|
type: "text",
|
|
520
520
|
text: {
|
|
521
521
|
content: _chunk
|
|
@@ -555,8 +555,8 @@ const $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])
|
|
|
555
555
|
])
|
|
556
556
|
}
|
|
557
557
|
});
|
|
558
|
-
(0, $dxT2C$
|
|
559
|
-
const rowChildren = (0, $dxT2C$
|
|
558
|
+
(0, $dxT2C$lodash.each)(token.rows, (row)=>{
|
|
559
|
+
const rowChildren = (0, $dxT2C$lodash.map)(row, (rowCell)=>$bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest([
|
|
560
560
|
rowCell
|
|
561
561
|
]));
|
|
562
562
|
table.table.children.push({
|
|
@@ -571,9 +571,9 @@ const $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])
|
|
|
571
571
|
}
|
|
572
572
|
if (token.type === "list") {
|
|
573
573
|
const listType = token.items[0].task ? "to_do" : token.ordered ? "numbered_list_item" : "bulleted_list_item";
|
|
574
|
-
(0, $dxT2C$
|
|
574
|
+
(0, $dxT2C$lodash.each)(token.items, (item)=>{
|
|
575
575
|
const itemChildren = $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest(item.tokens);
|
|
576
|
-
const groupedItemChildren = (0, $dxT2C$
|
|
576
|
+
const groupedItemChildren = (0, $dxT2C$lodash.groupBy)(itemChildren, (x)=>x.type === "text" ? "other" : "list");
|
|
577
577
|
acc.push({
|
|
578
578
|
type: listType,
|
|
579
579
|
[listType]: {
|
|
@@ -587,34 +587,34 @@ const $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])
|
|
|
587
587
|
});
|
|
588
588
|
}
|
|
589
589
|
if (token.type === "em") {
|
|
590
|
-
(0, $dxT2C$
|
|
591
|
-
(0, $dxT2C$
|
|
590
|
+
(0, $dxT2C$lodash.each)(childData, (child)=>{
|
|
591
|
+
(0, $dxT2C$lodash.set)(child, [
|
|
592
592
|
"annotations",
|
|
593
593
|
"italic"
|
|
594
594
|
], true);
|
|
595
595
|
});
|
|
596
|
-
acc = (0, $dxT2C$
|
|
596
|
+
acc = (0, $dxT2C$lodash.concat)(acc, childData);
|
|
597
597
|
return acc;
|
|
598
598
|
}
|
|
599
599
|
if (token.type === "strong") {
|
|
600
|
-
(0, $dxT2C$
|
|
601
|
-
(0, $dxT2C$
|
|
600
|
+
(0, $dxT2C$lodash.each)(childData, (child)=>{
|
|
601
|
+
(0, $dxT2C$lodash.set)(child, [
|
|
602
602
|
"annotations",
|
|
603
603
|
"bold"
|
|
604
604
|
], true);
|
|
605
605
|
});
|
|
606
|
-
acc = (0, $dxT2C$
|
|
606
|
+
acc = (0, $dxT2C$lodash.concat)(acc, childData);
|
|
607
607
|
return acc;
|
|
608
608
|
}
|
|
609
609
|
if (token.type === "link") {
|
|
610
|
-
(0, $dxT2C$
|
|
611
|
-
if (child.text) (0, $dxT2C$
|
|
610
|
+
(0, $dxT2C$lodash.each)(childData, (child)=>{
|
|
611
|
+
if (child.text) (0, $dxT2C$lodash.set)(child, [
|
|
612
612
|
"text",
|
|
613
613
|
"link",
|
|
614
614
|
"url"
|
|
615
615
|
], token.href);
|
|
616
616
|
});
|
|
617
|
-
acc = (0, $dxT2C$
|
|
617
|
+
acc = (0, $dxT2C$lodash.concat)(acc, childData);
|
|
618
618
|
return acc;
|
|
619
619
|
}
|
|
620
620
|
if (token.type === "blockquote") {
|
|
@@ -626,18 +626,18 @@ const $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])
|
|
|
626
626
|
});
|
|
627
627
|
return acc;
|
|
628
628
|
}
|
|
629
|
-
if (!(0, $dxT2C$
|
|
630
|
-
acc = (0, $dxT2C$
|
|
629
|
+
if (!(0, $dxT2C$lodash.isEmpty)(childData)) {
|
|
630
|
+
acc = (0, $dxT2C$lodash.concat)(acc, childData);
|
|
631
631
|
return acc;
|
|
632
632
|
}
|
|
633
|
-
const text = (0, $dxT2C$
|
|
633
|
+
const text = (0, $dxT2C$lodash.get)(token, "text");
|
|
634
634
|
if (!text) return acc;
|
|
635
635
|
const textToInsert = (0, $5a7cb266718aeaae$export$2e2bcd8739ae039)(text);
|
|
636
636
|
// chunk the text into 2000 character chunks, should handle emojis and multi-byte characters
|
|
637
637
|
const textSplitByNewLine = textToInsert.split("\n");
|
|
638
|
-
const chunksOfChunks = (0, $dxT2C$
|
|
639
|
-
const chunksWithNewLines = (0, $dxT2C$
|
|
640
|
-
return (0, $dxT2C$
|
|
638
|
+
const chunksOfChunks = (0, $dxT2C$lodash.compact)((0, $dxT2C$lodash.map)(textSplitByNewLine, (chunk)=>$bc8e7b2fdb012b3a$var$chunkText(chunk)));
|
|
639
|
+
const chunksWithNewLines = (0, $dxT2C$lodash.flattenDeep)((0, $233848446ca33fe6$export$2e2bcd8739ae039)((0, $dxT2C$lodash.map)(chunksOfChunks, (chunk)=>{
|
|
640
|
+
return (0, $dxT2C$lodash.map)(chunk, (_chunk)=>({
|
|
641
641
|
type: "text",
|
|
642
642
|
text: {
|
|
643
643
|
content: _chunk
|
|
@@ -654,7 +654,7 @@ const $bc8e7b2fdb012b3a$var$parseMarkedTokenToNotionRequest = (tokens, acc = [])
|
|
|
654
654
|
content: "\n"
|
|
655
655
|
}
|
|
656
656
|
}));
|
|
657
|
-
(0, $dxT2C$
|
|
657
|
+
(0, $dxT2C$lodash.each)(chunksWithNewLines, (chunk)=>{
|
|
658
658
|
acc.push(chunk);
|
|
659
659
|
});
|
|
660
660
|
return acc;
|
|
@@ -676,7 +676,7 @@ var $bc8e7b2fdb012b3a$export$2e2bcd8739ae039 = $bc8e7b2fdb012b3a$var$convertMark
|
|
|
676
676
|
|
|
677
677
|
|
|
678
678
|
const $15b9b26a1f4728d9$var$parseMarkedTokenToSlackRequest = (tokens, acc = [])=>{
|
|
679
|
-
return (0, $dxT2C$
|
|
679
|
+
return (0, $dxT2C$lodash.reduce)(tokens, (acc, token)=>{
|
|
680
680
|
if (token.type === "hr") {
|
|
681
681
|
acc.push({
|
|
682
682
|
type: "divider"
|
|
@@ -702,22 +702,22 @@ const $15b9b26a1f4728d9$var$parseMarkedTokenToSlackRequest = (tokens, acc = [])=
|
|
|
702
702
|
return acc;
|
|
703
703
|
}
|
|
704
704
|
if (token.type === "paragraph" || token.type === "text") {
|
|
705
|
-
const childTokens = (0, $dxT2C$
|
|
705
|
+
const childTokens = (0, $dxT2C$lodash.get)(token, "tokens");
|
|
706
706
|
let childData = [];
|
|
707
707
|
if (childTokens) childData = $15b9b26a1f4728d9$var$parseMarkedTokenToSlackRequest(childTokens);
|
|
708
708
|
else {
|
|
709
709
|
acc.push(token.raw);
|
|
710
710
|
return acc;
|
|
711
711
|
}
|
|
712
|
-
const childDataGroupedByType = (0, $dxT2C$
|
|
713
|
-
if (!(0, $dxT2C$
|
|
712
|
+
const childDataGroupedByType = (0, $dxT2C$lodash.groupBy)(childData, (x)=>(0, $dxT2C$lodash.isString)(x) ? "text" : "block");
|
|
713
|
+
if (!(0, $dxT2C$lodash.isEmpty)(childDataGroupedByType.text)) acc.push({
|
|
714
714
|
type: "section",
|
|
715
715
|
text: {
|
|
716
716
|
type: "mrkdwn",
|
|
717
|
-
text: (0, $dxT2C$
|
|
717
|
+
text: (0, $dxT2C$lodash.join)(childDataGroupedByType.text, "")
|
|
718
718
|
}
|
|
719
719
|
});
|
|
720
|
-
if (!(0, $dxT2C$
|
|
720
|
+
if (!(0, $dxT2C$lodash.isEmpty)(childDataGroupedByType.block)) acc = (0, $dxT2C$lodash.concat)(acc, childDataGroupedByType.block);
|
|
721
721
|
return acc;
|
|
722
722
|
}
|
|
723
723
|
if (token.type === "heading") {
|
|
@@ -732,13 +732,13 @@ const $15b9b26a1f4728d9$var$parseMarkedTokenToSlackRequest = (tokens, acc = [])=
|
|
|
732
732
|
return acc;
|
|
733
733
|
}
|
|
734
734
|
if (token.type === "list") {
|
|
735
|
-
const items = (0, $dxT2C$
|
|
736
|
-
const childTokens = (0, $dxT2C$
|
|
735
|
+
const items = (0, $dxT2C$lodash.map)(token.items, (item)=>{
|
|
736
|
+
const childTokens = (0, $dxT2C$lodash.get)(item, "tokens");
|
|
737
737
|
let childData = [];
|
|
738
738
|
if (childTokens) childData = $15b9b26a1f4728d9$var$parseMarkedTokenToSlackRequest(childTokens);
|
|
739
739
|
return childData;
|
|
740
740
|
});
|
|
741
|
-
const listString = (0, $dxT2C$
|
|
741
|
+
const listString = (0, $dxT2C$lodash.join)((0, $dxT2C$lodash.filter)((0, $dxT2C$lodash.flattenDeep)(items), (x)=>!!(0, $dxT2C$lodash.get)(x, "text.text")).map((x, index)=>`${token.ordered ? `${index + 1}.` : "•"} ${(0, $dxT2C$lodash.get)(x, "text.text")}`), "\n");
|
|
742
742
|
acc.push({
|
|
743
743
|
type: "section",
|
|
744
744
|
text: {
|
|
@@ -783,7 +783,7 @@ const $15b9b26a1f4728d9$var$parseMarkedTokenToSlackRequest = (tokens, acc = [])=
|
|
|
783
783
|
const $15b9b26a1f4728d9$var$convertMarkdownToSlack = (text)=>{
|
|
784
784
|
const tokens = (0, $dxT2C$marked.Lexer).lex(text);
|
|
785
785
|
const parsedTokens = $15b9b26a1f4728d9$var$parseMarkedTokenToSlackRequest(tokens);
|
|
786
|
-
return (0, $dxT2C$
|
|
786
|
+
return (0, $dxT2C$lodash.filter)(parsedTokens, (x)=>!(0, $dxT2C$lodash.isString)(x));
|
|
787
787
|
};
|
|
788
788
|
var $15b9b26a1f4728d9$export$2e2bcd8739ae039 = $15b9b26a1f4728d9$var$convertMarkdownToSlack;
|
|
789
789
|
|
|
@@ -817,11 +817,11 @@ const $6c8155c4308ceae8$var$convertNotionToMd = function(block, level = 1) {
|
|
|
817
817
|
case "bookmark":
|
|
818
818
|
return `[${data.url}](data.url)${n}`;
|
|
819
819
|
case "bulleted_list_item":
|
|
820
|
-
childData = (0, $dxT2C$
|
|
821
|
-
return `- ${plainText.join("")}\n` + (childData ? `${(0, $dxT2C$
|
|
820
|
+
childData = (0, $dxT2C$lodash.map)(block.children, (child)=>$6c8155c4308ceae8$var$convertNotionToMd(child, level + 1)).join((0, $dxT2C$lodash.repeat)(" ", level));
|
|
821
|
+
return `- ${plainText.join("")}\n` + (childData ? `${(0, $dxT2C$lodash.repeat)(" ", level)}${childData}` : "");
|
|
822
822
|
case "numbered_list_item":
|
|
823
|
-
childData = (0, $dxT2C$
|
|
824
|
-
return `${block.number}. ${plainText.join("")}\n` + (childData ? `${(0, $dxT2C$
|
|
823
|
+
childData = (0, $dxT2C$lodash.map)(block.children, (child)=>$6c8155c4308ceae8$var$convertNotionToMd(child, level + 1)).join((0, $dxT2C$lodash.repeat)(" ", level));
|
|
824
|
+
return `${block.number}. ${plainText.join("")}\n` + (childData ? `${(0, $dxT2C$lodash.repeat)(" ", level)}${childData}` : "");
|
|
825
825
|
case "quote":
|
|
826
826
|
case "callout":
|
|
827
827
|
return `> ${plainText.join("")}${n}`;
|
|
@@ -858,7 +858,7 @@ const $6c8155c4308ceae8$var$convertNotionToMd = function(block, level = 1) {
|
|
|
858
858
|
const firstChild = block.children[0];
|
|
859
859
|
const remainingChildren = block.children.slice(1);
|
|
860
860
|
const header = `| ${firstChild.table_row.cells.map((x)=>x.map((y)=>$6c8155c4308ceae8$var$formatPlainText(y)).join("")).join(" | ")} |\n`;
|
|
861
|
-
const divider = `|${(0, $dxT2C$
|
|
861
|
+
const divider = `|${(0, $dxT2C$lodash.repeat)("---|", data.table_width)}\n`;
|
|
862
862
|
const rows = remainingChildren.map((row)=>{
|
|
863
863
|
return `| ${row.table_row.cells.map((x)=>x.map((y)=>$6c8155c4308ceae8$var$formatPlainText(y)).join("")).join(" | ")} |`;
|
|
864
864
|
}).join("\n");
|
|
@@ -868,10 +868,10 @@ const $6c8155c4308ceae8$var$convertNotionToMd = function(block, level = 1) {
|
|
|
868
868
|
case "table_row":
|
|
869
869
|
return `| ${data.cells.map((x)=>x.map((y)=>$6c8155c4308ceae8$var$formatPlainText(y)).join("")).join(" | ")} |\n`;
|
|
870
870
|
case "to_do":
|
|
871
|
-
childData = (0, $dxT2C$
|
|
872
|
-
return `- [${data.checked ? "X" : " "}] ${plainText.join("")}\n` + (childData ? `${(0, $dxT2C$
|
|
871
|
+
childData = (0, $dxT2C$lodash.map)(block.children, (child)=>$6c8155c4308ceae8$var$convertNotionToMd(child, level + 1)).join((0, $dxT2C$lodash.repeat)(" ", level));
|
|
872
|
+
return `- [${data.checked ? "X" : " "}] ${plainText.join("")}\n` + (childData ? `${(0, $dxT2C$lodash.repeat)(" ", level)}${childData}` : "");
|
|
873
873
|
default:
|
|
874
|
-
childData = (0, $dxT2C$
|
|
874
|
+
childData = (0, $dxT2C$lodash.map)(block.children, (child)=>$6c8155c4308ceae8$var$convertNotionToMd(child)).join("");
|
|
875
875
|
return plainText.join("") + n + childData;
|
|
876
876
|
}
|
|
877
877
|
};
|
|
@@ -904,7 +904,7 @@ const $6c8155c4308ceae8$var$insertNewLinesBetweenLists = function(blocks) {
|
|
|
904
904
|
"numbered_list_item",
|
|
905
905
|
"bulleted_list_item"
|
|
906
906
|
];
|
|
907
|
-
return (0, $dxT2C$
|
|
907
|
+
return (0, $dxT2C$lodash.flatten)(blocks.map((block, index)=>{
|
|
908
908
|
const nextBlock = blocks[index + 1];
|
|
909
909
|
const nextBlockType = nextBlock?.type;
|
|
910
910
|
if (listBlocks.includes(block.type) && !listBlocks.includes(nextBlockType)) return [
|
|
@@ -921,8 +921,8 @@ const $6c8155c4308ceae8$var$insertNewLinesBetweenLists = function(blocks) {
|
|
|
921
921
|
}));
|
|
922
922
|
};
|
|
923
923
|
const $6c8155c4308ceae8$var$convertNotionToMarkdown = function(blocks) {
|
|
924
|
-
const arrayBlocks = $6c8155c4308ceae8$var$insertNewLinesBetweenLists((0, $dxT2C$
|
|
925
|
-
const parentBlocks = (0, $dxT2C$
|
|
924
|
+
const arrayBlocks = $6c8155c4308ceae8$var$insertNewLinesBetweenLists((0, $dxT2C$lodash.castArray)(blocks));
|
|
925
|
+
const parentBlocks = (0, $dxT2C$lodash.reject)(arrayBlocks, (block)=>block.parent?.type === "block_id");
|
|
926
926
|
const blocksWithChildren = $6c8155c4308ceae8$var$numberOrderedLists(parentBlocks.map((block)=>{
|
|
927
927
|
return $6c8155c4308ceae8$var$resolveChildren(block, arrayBlocks);
|
|
928
928
|
}));
|
|
@@ -1242,8 +1242,8 @@ var $61d34cb0b1d98121$export$2e2bcd8739ae039 = $61d34cb0b1d98121$var$firstNonEmp
|
|
|
1242
1242
|
|
|
1243
1243
|
|
|
1244
1244
|
async function $caaee789061bb8bb$var$generateEmbeddingsCohere(body, api_key) {
|
|
1245
|
-
if (!(0, $dxT2C$
|
|
1246
|
-
const chunks = (0, $dxT2C$
|
|
1245
|
+
if (!(0, $dxT2C$lodash.isEmpty)(body.texts)) {
|
|
1246
|
+
const chunks = (0, $dxT2C$lodash.chunk)((0, $dxT2C$lodash.castArray)(body.texts), 20);
|
|
1247
1247
|
return await (0, ($parcel$interopDefault($dxT2C$pmap)))(chunks, async (chunk)=>{
|
|
1248
1248
|
return await (0, ($parcel$interopDefault($dxT2C$pretry)))(async ()=>{
|
|
1249
1249
|
const response = await fetch("https://api.cohere.com/v2/embed", {
|
|
@@ -1273,7 +1273,7 @@ async function $caaee789061bb8bb$var$generateEmbeddingsCohere(body, api_key) {
|
|
|
1273
1273
|
}, {
|
|
1274
1274
|
concurrency: 1
|
|
1275
1275
|
});
|
|
1276
|
-
} else if (!(0, $dxT2C$
|
|
1276
|
+
} else if (!(0, $dxT2C$lodash.isEmpty)(body.images)) return await (0, ($parcel$interopDefault($dxT2C$pretry)))(async ()=>{
|
|
1277
1277
|
const response = await fetch("https://api.cohere.com/v2/embed", {
|
|
1278
1278
|
method: "POST",
|
|
1279
1279
|
headers: {
|
|
@@ -1301,7 +1301,7 @@ var $caaee789061bb8bb$export$2e2bcd8739ae039 = $caaee789061bb8bb$var$generateEmb
|
|
|
1301
1301
|
|
|
1302
1302
|
|
|
1303
1303
|
async function $5e0a134878b8be39$var$getArrayBuffer(file) {
|
|
1304
|
-
return file && (0, $dxT2C$
|
|
1304
|
+
return file && (0, $dxT2C$lodash.isFunction)(file.arrayBuffer) ? await file.arrayBuffer() : undefined;
|
|
1305
1305
|
}
|
|
1306
1306
|
var $5e0a134878b8be39$export$2e2bcd8739ae039 = $5e0a134878b8be39$var$getArrayBuffer;
|
|
1307
1307
|
|
|
@@ -1362,7 +1362,7 @@ function $06ecced17a74bf4a$var$getNormalizedString(value) {
|
|
|
1362
1362
|
}
|
|
1363
1363
|
function $06ecced17a74bf4a$var$mostSimilar(value, possibleValues, threshold = 0.8) {
|
|
1364
1364
|
const normalizedValue = $06ecced17a74bf4a$var$getNormalizedString(value);
|
|
1365
|
-
const result = (0, $dxT2C$
|
|
1365
|
+
const result = (0, $dxT2C$lodash.reduce)(possibleValues, (acc, possibleValue)=>{
|
|
1366
1366
|
const normalizedPossibleValue = $06ecced17a74bf4a$var$getNormalizedString(possibleValue);
|
|
1367
1367
|
const similarity = (0, $dxT2C$dicecoefficient.diceCoefficient)(normalizedValue, normalizedPossibleValue);
|
|
1368
1368
|
if (similarity > acc.similarity) return {
|
|
@@ -1430,9 +1430,9 @@ async function $fe4dcef142601b8c$export$e600492876ee595b(text, options = {
|
|
|
1430
1430
|
chunkOverlap: 60
|
|
1431
1431
|
}) {
|
|
1432
1432
|
let textToSplit;
|
|
1433
|
-
if ((0, $dxT2C$
|
|
1434
|
-
else if ((0, $dxT2C$
|
|
1435
|
-
else textToSplit = (0, $dxT2C$
|
|
1433
|
+
if ((0, $dxT2C$lodash.isString)(text)) textToSplit = text;
|
|
1434
|
+
else if ((0, $dxT2C$lodash.isPlainObject)(text) || (0, $dxT2C$lodash.isArray)(text)) textToSplit = JSON.stringify(text, null, 2);
|
|
1435
|
+
else textToSplit = (0, $dxT2C$lodash.toString)(text);
|
|
1436
1436
|
const splitter = new (0, $dxT2C$langchaintextsplitters.RecursiveCharacterTextSplitter)(options);
|
|
1437
1437
|
return splitter.splitText(textToSplit);
|
|
1438
1438
|
}
|
|
@@ -1480,7 +1480,7 @@ function $0a764cc1e9fed37c$export$96d07f33920abf3e(array, idKey = "id", parentId
|
|
|
1480
1480
|
const nodeMap = new Map();
|
|
1481
1481
|
// Populate the map
|
|
1482
1482
|
array.forEach((node)=>{
|
|
1483
|
-
nodeMap.set((0, $dxT2C$
|
|
1483
|
+
nodeMap.set((0, $dxT2C$lodash.get)(node, idKey), {
|
|
1484
1484
|
...node,
|
|
1485
1485
|
children: []
|
|
1486
1486
|
});
|
|
@@ -1489,8 +1489,8 @@ function $0a764cc1e9fed37c$export$96d07f33920abf3e(array, idKey = "id", parentId
|
|
|
1489
1489
|
const rootNodes = [];
|
|
1490
1490
|
// Step 3: Organize the nodes into a tree structure
|
|
1491
1491
|
array.forEach((node)=>{
|
|
1492
|
-
const parentId = (0, $dxT2C$
|
|
1493
|
-
const nodeId = (0, $dxT2C$
|
|
1492
|
+
const parentId = (0, $dxT2C$lodash.get)(node, parentIdKey);
|
|
1493
|
+
const nodeId = (0, $dxT2C$lodash.get)(node, idKey);
|
|
1494
1494
|
if (parentId && nodeMap.has(parentId)) // If the parent exists, add the current node as a child
|
|
1495
1495
|
nodeMap.get(parentId)?.children?.push(nodeMap.get(nodeId));
|
|
1496
1496
|
else // Treat it as a root node if the parent doesn't exist or it's null
|
|
@@ -1499,7 +1499,7 @@ function $0a764cc1e9fed37c$export$96d07f33920abf3e(array, idKey = "id", parentId
|
|
|
1499
1499
|
// Step 4: Recursive function to sort nodes and their children
|
|
1500
1500
|
function sortTree(nodes) {
|
|
1501
1501
|
// Sort nodes using lodash by sequence
|
|
1502
|
-
const sortedNodes = (0, $dxT2C$
|
|
1502
|
+
const sortedNodes = (0, $dxT2C$lodash.sortBy)(nodes, sequenceKey);
|
|
1503
1503
|
sortedNodes.forEach((node)=>{
|
|
1504
1504
|
if (node.children && node.children.length > 0) node.children = sortTree(node.children);
|
|
1505
1505
|
});
|
|
@@ -1510,7 +1510,7 @@ function $0a764cc1e9fed37c$export$96d07f33920abf3e(array, idKey = "id", parentId
|
|
|
1510
1510
|
// Step 6: Flatten the sorted tree into an array (keeping the parent-child structure)
|
|
1511
1511
|
function flattenTree(nodes) {
|
|
1512
1512
|
return nodes.reduce((acc, node)=>{
|
|
1513
|
-
acc.push((0, $dxT2C$
|
|
1513
|
+
acc.push((0, $dxT2C$lodash.omit)(node, "children")) // Push the current node without 'children'
|
|
1514
1514
|
;
|
|
1515
1515
|
if (node.children && node.children.length > 0) acc.push(...flattenTree(node.children)) // Recursively flatten children
|
|
1516
1516
|
;
|
|
@@ -1536,7 +1536,7 @@ var $9a2529096849a04f$export$2e2bcd8739ae039 = $9a2529096849a04f$var$teeStream;
|
|
|
1536
1536
|
|
|
1537
1537
|
|
|
1538
1538
|
function $49ae26210d3b6a4c$var$toNumber(value) {
|
|
1539
|
-
return (0, $dxT2C$
|
|
1539
|
+
return (0, $dxT2C$lodash.toNumber)(value);
|
|
1540
1540
|
}
|
|
1541
1541
|
var $49ae26210d3b6a4c$export$2e2bcd8739ae039 = $49ae26210d3b6a4c$var$toNumber;
|
|
1542
1542
|
|
|
@@ -1591,7 +1591,7 @@ function $af351c41b7fd6f79$export$2e2bcd8739ae039(expression) {
|
|
|
1591
1591
|
expression.registerFunction("convertMarkdownToSlack", (0, $15b9b26a1f4728d9$export$2e2bcd8739ae039));
|
|
1592
1592
|
expression.registerFunction("parseUrl", (0, $2bc8364dc45b0cc5$export$2e2bcd8739ae039));
|
|
1593
1593
|
expression.registerFunction("difference", function(arr1, arr2) {
|
|
1594
|
-
return (0, $dxT2C$
|
|
1594
|
+
return (0, $dxT2C$lodash.difference)(arr1, arr2);
|
|
1595
1595
|
});
|
|
1596
1596
|
expression.registerFunction("toNumber", (0, $49ae26210d3b6a4c$export$2e2bcd8739ae039));
|
|
1597
1597
|
expression.registerFunction("jsonParse", (0, $491a3e93ed46e445$export$2e2bcd8739ae039));
|
|
@@ -1609,40 +1609,40 @@ function $af351c41b7fd6f79$export$2e2bcd8739ae039(expression) {
|
|
|
1609
1609
|
expression.registerFunction("jsToXml", (0, $c7a445cfc49817c1$export$2e2bcd8739ae039));
|
|
1610
1610
|
expression.registerFunction("generateEmbeddingsCohere", (0, $caaee789061bb8bb$export$2e2bcd8739ae039));
|
|
1611
1611
|
expression.registerFunction("groupBy", function(array, key) {
|
|
1612
|
-
return (0, $dxT2C$
|
|
1612
|
+
return (0, $dxT2C$lodash.groupBy)((0, $dxT2C$lodash.castArray)(array), key);
|
|
1613
1613
|
});
|
|
1614
1614
|
expression.registerFunction("keyBy", function(array, key) {
|
|
1615
|
-
return (0, $dxT2C$
|
|
1615
|
+
return (0, $dxT2C$lodash.keyBy)((0, $dxT2C$lodash.castArray)(array), key);
|
|
1616
1616
|
});
|
|
1617
1617
|
expression.registerFunction("pick", function(obj, keys) {
|
|
1618
|
-
return (0, $dxT2C$
|
|
1618
|
+
return (0, $dxT2C$lodash.pick)(obj, keys);
|
|
1619
1619
|
});
|
|
1620
1620
|
expression.registerFunction("omit", function(obj, keys) {
|
|
1621
|
-
return (0, $dxT2C$
|
|
1621
|
+
return (0, $dxT2C$lodash.omit)(obj, keys);
|
|
1622
1622
|
});
|
|
1623
1623
|
expression.registerFunction("compact", function(arr) {
|
|
1624
|
-
return (0, $dxT2C$
|
|
1624
|
+
return (0, $dxT2C$lodash.compact)((0, $dxT2C$lodash.castArray)(arr));
|
|
1625
1625
|
});
|
|
1626
1626
|
expression.registerFunction("join", function(arr, separator) {
|
|
1627
|
-
return (0, $dxT2C$
|
|
1627
|
+
return (0, $dxT2C$lodash.join)((0, $dxT2C$lodash.castArray)(arr), separator);
|
|
1628
1628
|
});
|
|
1629
1629
|
expression.registerFunction("orderBy", function(arr, attr, order) {
|
|
1630
|
-
return (0, $dxT2C$
|
|
1630
|
+
return (0, $dxT2C$lodash.orderBy)((0, $dxT2C$lodash.castArray)(arr), attr, order);
|
|
1631
1631
|
});
|
|
1632
1632
|
expression.registerFunction("find", function(arr, attr) {
|
|
1633
|
-
return (0, $dxT2C$
|
|
1633
|
+
return (0, $dxT2C$lodash.find)((0, $dxT2C$lodash.castArray)(arr), attr);
|
|
1634
1634
|
});
|
|
1635
1635
|
expression.registerFunction("lofilter", function(arr, attr) {
|
|
1636
|
-
return (0, $dxT2C$
|
|
1636
|
+
return (0, $dxT2C$lodash.filter)((0, $dxT2C$lodash.castArray)(arr), attr);
|
|
1637
1637
|
});
|
|
1638
1638
|
expression.registerFunction("values", function(obj) {
|
|
1639
|
-
return (0, $dxT2C$
|
|
1639
|
+
return (0, $dxT2C$lodash.values)(obj);
|
|
1640
1640
|
});
|
|
1641
1641
|
expression.registerFunction("chunk", function(arr, size) {
|
|
1642
|
-
return (0, $dxT2C$
|
|
1642
|
+
return (0, $dxT2C$lodash.chunk)((0, $dxT2C$lodash.castArray)(arr), size);
|
|
1643
1643
|
});
|
|
1644
1644
|
expression.registerFunction("wrap", function(value, wrapper, endWrapper) {
|
|
1645
|
-
return (0, $dxT2C$
|
|
1645
|
+
return (0, $dxT2C$lodash.join)([
|
|
1646
1646
|
wrapper,
|
|
1647
1647
|
value,
|
|
1648
1648
|
endWrapper || wrapper
|
|
@@ -1656,13 +1656,13 @@ function $af351c41b7fd6f79$export$2e2bcd8739ae039(expression) {
|
|
|
1656
1656
|
expression.registerFunction("parseQuery", (0, $7161d3cc11fbd965$export$2e2bcd8739ae039));
|
|
1657
1657
|
expression.registerFunction("stringifyQuery", (0, $d3ad656830753df3$export$2e2bcd8739ae039));
|
|
1658
1658
|
expression.registerFunction("flatten", function(arr) {
|
|
1659
|
-
return (0, $dxT2C$
|
|
1659
|
+
return (0, $dxT2C$lodash.flatten)((0, $dxT2C$lodash.castArray)(arr));
|
|
1660
1660
|
});
|
|
1661
1661
|
expression.registerFunction("flattenDeep", function(arr) {
|
|
1662
|
-
return (0, $dxT2C$
|
|
1662
|
+
return (0, $dxT2C$lodash.flattenDeep)((0, $dxT2C$lodash.castArray)(arr));
|
|
1663
1663
|
});
|
|
1664
1664
|
expression.registerFunction("flattenDepth", function(arr, depth) {
|
|
1665
|
-
return (0, $dxT2C$
|
|
1665
|
+
return (0, $dxT2C$lodash.flattenDepth)((0, $dxT2C$lodash.castArray)(arr), depth);
|
|
1666
1666
|
});
|
|
1667
1667
|
return expression;
|
|
1668
1668
|
}
|