@promptbook/markdown-utils 0.77.0 → 0.78.0-0
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/README.md +4 -0
- package/esm/index.es.js +575 -544
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +8 -2
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -8
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandType.d.ts +17 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +1 -1
- package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts} +2 -2
- package/esm/typings/src/conversion/utils/removePipelineCommand.d.ts +22 -0
- package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts} +3 -3
- package/esm/typings/src/errors/0-index.d.ts +46 -1
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/titleToName.test.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +578 -547
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/conversion/utils/{extractVariables.test.d.ts → extractVariablesFromScript.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{renameParameter.test.d.ts → removePipelineCommand.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{titleToName.test.d.ts → renamePipelineParameter.test.d.ts} +0 -0
- /package/esm/typings/src/{conversion/utils → utils/normalization}/titleToName.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { format } from 'prettier';
|
|
3
3
|
import parserHtml from 'prettier/parser-html';
|
|
4
|
-
import { basename, join } from 'path';
|
|
5
4
|
import { forTime } from 'waitasecond';
|
|
5
|
+
import { join, basename } from 'path';
|
|
6
6
|
import { SHA256 } from 'crypto-js';
|
|
7
7
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
8
8
|
import { lookup } from 'mime-types';
|
|
@@ -20,7 +20,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
20
20
|
*
|
|
21
21
|
* @see https://github.com/webgptorg/promptbook
|
|
22
22
|
*/
|
|
23
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.77.
|
|
23
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.77.1';
|
|
24
24
|
/**
|
|
25
25
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
26
26
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1562,415 +1562,26 @@ function createCollectionFromJson() {
|
|
|
1562
1562
|
return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
1563
1563
|
}
|
|
1564
1564
|
|
|
1565
|
-
var defaultDiacriticsRemovalMap = [
|
|
1566
|
-
{
|
|
1567
|
-
base: 'A',
|
|
1568
|
-
letters: '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F',
|
|
1569
|
-
},
|
|
1570
|
-
{ base: 'AA', letters: '\uA732' },
|
|
1571
|
-
{ base: 'AE', letters: '\u00C6\u01FC\u01E2' },
|
|
1572
|
-
{ base: 'AO', letters: '\uA734' },
|
|
1573
|
-
{ base: 'AU', letters: '\uA736' },
|
|
1574
|
-
{ base: 'AV', letters: '\uA738\uA73A' },
|
|
1575
|
-
{ base: 'AY', letters: '\uA73C' },
|
|
1576
|
-
{
|
|
1577
|
-
base: 'B',
|
|
1578
|
-
letters: '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181',
|
|
1579
|
-
},
|
|
1580
|
-
{
|
|
1581
|
-
base: 'C',
|
|
1582
|
-
letters: '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E',
|
|
1583
|
-
},
|
|
1584
|
-
{
|
|
1585
|
-
base: 'D',
|
|
1586
|
-
letters: '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0',
|
|
1587
|
-
},
|
|
1588
|
-
{ base: 'DZ', letters: '\u01F1\u01C4' },
|
|
1589
|
-
{ base: 'Dz', letters: '\u01F2\u01C5' },
|
|
1590
|
-
{
|
|
1591
|
-
base: 'E',
|
|
1592
|
-
letters: '\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E',
|
|
1593
|
-
},
|
|
1594
|
-
{ base: 'F', letters: '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' },
|
|
1595
|
-
{
|
|
1596
|
-
base: 'G',
|
|
1597
|
-
letters: '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E',
|
|
1598
|
-
},
|
|
1599
|
-
{
|
|
1600
|
-
base: 'H',
|
|
1601
|
-
letters: '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D',
|
|
1602
|
-
},
|
|
1603
|
-
{
|
|
1604
|
-
base: 'I',
|
|
1605
|
-
letters: '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197',
|
|
1606
|
-
},
|
|
1607
|
-
{ base: 'J', letters: '\u004A\u24BF\uFF2A\u0134\u0248' },
|
|
1608
|
-
{
|
|
1609
|
-
base: 'K',
|
|
1610
|
-
letters: '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2',
|
|
1611
|
-
},
|
|
1612
|
-
{
|
|
1613
|
-
base: 'L',
|
|
1614
|
-
letters: '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780',
|
|
1615
|
-
},
|
|
1616
|
-
{ base: 'LJ', letters: '\u01C7' },
|
|
1617
|
-
{ base: 'Lj', letters: '\u01C8' },
|
|
1618
|
-
{ base: 'M', letters: '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' },
|
|
1619
|
-
{
|
|
1620
|
-
base: 'N',
|
|
1621
|
-
letters: '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4',
|
|
1622
|
-
},
|
|
1623
|
-
{ base: 'NJ', letters: '\u01CA' },
|
|
1624
|
-
{ base: 'Nj', letters: '\u01CB' },
|
|
1625
|
-
{
|
|
1626
|
-
base: 'O',
|
|
1627
|
-
letters: '\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C',
|
|
1628
|
-
},
|
|
1629
|
-
{ base: 'OI', letters: '\u01A2' },
|
|
1630
|
-
{ base: 'OO', letters: '\uA74E' },
|
|
1631
|
-
{ base: 'OU', letters: '\u0222' },
|
|
1632
|
-
{ base: 'OE', letters: '\u008C\u0152' },
|
|
1633
|
-
{ base: 'oe', letters: '\u009C\u0153' },
|
|
1634
|
-
{
|
|
1635
|
-
base: 'P',
|
|
1636
|
-
letters: '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754',
|
|
1637
|
-
},
|
|
1638
|
-
{ base: 'Q', letters: '\u0051\u24C6\uFF31\uA756\uA758\u024A' },
|
|
1639
|
-
{
|
|
1640
|
-
base: 'R',
|
|
1641
|
-
letters: '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782',
|
|
1642
|
-
},
|
|
1643
|
-
{
|
|
1644
|
-
base: 'S',
|
|
1645
|
-
letters: '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784',
|
|
1646
|
-
},
|
|
1647
|
-
{
|
|
1648
|
-
base: 'T',
|
|
1649
|
-
letters: '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786',
|
|
1650
|
-
},
|
|
1651
|
-
{ base: 'TZ', letters: '\uA728' },
|
|
1652
|
-
{
|
|
1653
|
-
base: 'U',
|
|
1654
|
-
letters: '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244',
|
|
1655
|
-
},
|
|
1656
|
-
{ base: 'V', letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' },
|
|
1657
|
-
{ base: 'VY', letters: '\uA760' },
|
|
1658
|
-
{
|
|
1659
|
-
base: 'W',
|
|
1660
|
-
letters: '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72',
|
|
1661
|
-
},
|
|
1662
|
-
{ base: 'X', letters: '\u0058\u24CD\uFF38\u1E8A\u1E8C' },
|
|
1663
|
-
{
|
|
1664
|
-
base: 'Y',
|
|
1665
|
-
letters: '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE',
|
|
1666
|
-
},
|
|
1667
|
-
{
|
|
1668
|
-
base: 'Z',
|
|
1669
|
-
letters: '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762',
|
|
1670
|
-
},
|
|
1671
|
-
{
|
|
1672
|
-
base: 'a',
|
|
1673
|
-
letters: '\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250',
|
|
1674
|
-
},
|
|
1675
|
-
{ base: 'aa', letters: '\uA733' },
|
|
1676
|
-
{ base: 'ae', letters: '\u00E6\u01FD\u01E3' },
|
|
1677
|
-
{ base: 'ao', letters: '\uA735' },
|
|
1678
|
-
{ base: 'au', letters: '\uA737' },
|
|
1679
|
-
{ base: 'av', letters: '\uA739\uA73B' },
|
|
1680
|
-
{ base: 'ay', letters: '\uA73D' },
|
|
1681
|
-
{
|
|
1682
|
-
base: 'b',
|
|
1683
|
-
letters: '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253',
|
|
1684
|
-
},
|
|
1685
|
-
{
|
|
1686
|
-
base: 'c',
|
|
1687
|
-
letters: '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184',
|
|
1688
|
-
},
|
|
1689
|
-
{
|
|
1690
|
-
base: 'd',
|
|
1691
|
-
letters: '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A',
|
|
1692
|
-
},
|
|
1693
|
-
{ base: 'dz', letters: '\u01F3\u01C6' },
|
|
1694
|
-
{
|
|
1695
|
-
base: 'e',
|
|
1696
|
-
letters: '\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD',
|
|
1697
|
-
},
|
|
1698
|
-
{ base: 'f', letters: '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' },
|
|
1699
|
-
{
|
|
1700
|
-
base: 'g',
|
|
1701
|
-
letters: '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F',
|
|
1702
|
-
},
|
|
1703
|
-
{
|
|
1704
|
-
base: 'h',
|
|
1705
|
-
letters: '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265',
|
|
1706
|
-
},
|
|
1707
|
-
{ base: 'hv', letters: '\u0195' },
|
|
1708
|
-
{
|
|
1709
|
-
base: 'i',
|
|
1710
|
-
letters: '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131',
|
|
1711
|
-
},
|
|
1712
|
-
{ base: 'j', letters: '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' },
|
|
1713
|
-
{
|
|
1714
|
-
base: 'k',
|
|
1715
|
-
letters: '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3',
|
|
1716
|
-
},
|
|
1717
|
-
{
|
|
1718
|
-
base: 'l',
|
|
1719
|
-
letters: '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747',
|
|
1720
|
-
},
|
|
1721
|
-
{ base: 'lj', letters: '\u01C9' },
|
|
1722
|
-
{ base: 'm', letters: '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' },
|
|
1723
|
-
{
|
|
1724
|
-
base: 'n',
|
|
1725
|
-
letters: '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5',
|
|
1726
|
-
},
|
|
1727
|
-
{ base: 'nj', letters: '\u01CC' },
|
|
1728
|
-
{
|
|
1729
|
-
base: 'o',
|
|
1730
|
-
letters: '\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275',
|
|
1731
|
-
},
|
|
1732
|
-
{ base: 'oi', letters: '\u01A3' },
|
|
1733
|
-
{ base: 'ou', letters: '\u0223' },
|
|
1734
|
-
{ base: 'oo', letters: '\uA74F' },
|
|
1735
|
-
{
|
|
1736
|
-
base: 'p',
|
|
1737
|
-
letters: '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755',
|
|
1738
|
-
},
|
|
1739
|
-
{ base: 'q', letters: '\u0071\u24E0\uFF51\u024B\uA757\uA759' },
|
|
1740
|
-
{
|
|
1741
|
-
base: 'r',
|
|
1742
|
-
letters: '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783',
|
|
1743
|
-
},
|
|
1744
|
-
{
|
|
1745
|
-
base: 's',
|
|
1746
|
-
letters: '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B',
|
|
1747
|
-
},
|
|
1748
|
-
{
|
|
1749
|
-
base: 't',
|
|
1750
|
-
letters: '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787',
|
|
1751
|
-
},
|
|
1752
|
-
{ base: 'tz', letters: '\uA729' },
|
|
1753
|
-
{
|
|
1754
|
-
base: 'u',
|
|
1755
|
-
letters: '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289',
|
|
1756
|
-
},
|
|
1757
|
-
{ base: 'v', letters: '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' },
|
|
1758
|
-
{ base: 'vy', letters: '\uA761' },
|
|
1759
|
-
{
|
|
1760
|
-
base: 'w',
|
|
1761
|
-
letters: '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73',
|
|
1762
|
-
},
|
|
1763
|
-
{ base: 'x', letters: '\u0078\u24E7\uFF58\u1E8B\u1E8D' },
|
|
1764
|
-
{
|
|
1765
|
-
base: 'y',
|
|
1766
|
-
letters: '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF',
|
|
1767
|
-
},
|
|
1768
|
-
{
|
|
1769
|
-
base: 'z',
|
|
1770
|
-
letters: '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763',
|
|
1771
|
-
},
|
|
1772
|
-
];
|
|
1773
1565
|
/**
|
|
1774
|
-
*
|
|
1775
|
-
* Contains lowercase and uppercase separatelly
|
|
1776
|
-
*
|
|
1777
|
-
* > "á" => "a"
|
|
1778
|
-
* > "ě" => "e"
|
|
1779
|
-
* > "Ă" => "A"
|
|
1780
|
-
* > ...
|
|
1566
|
+
* This error type indicates that some tools are missing for pipeline execution or preparation
|
|
1781
1567
|
*
|
|
1782
|
-
* @public exported from `@promptbook/
|
|
1568
|
+
* @public exported from `@promptbook/core`
|
|
1783
1569
|
*/
|
|
1784
|
-
var
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1570
|
+
var MissingToolsError = /** @class */ (function (_super) {
|
|
1571
|
+
__extends(MissingToolsError, _super);
|
|
1572
|
+
function MissingToolsError(message) {
|
|
1573
|
+
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: You have probbably forgot to provide some tools for pipeline execution or preparation\n\n "); })) || this;
|
|
1574
|
+
_this.name = 'MissingToolsError';
|
|
1575
|
+
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
1576
|
+
return _this;
|
|
1791
1577
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
/*
|
|
1795
|
-
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
1796
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1797
|
-
you may not use this file except in compliance with the License.
|
|
1798
|
-
You may obtain a copy of the License at
|
|
1799
|
-
|
|
1800
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
1801
|
-
|
|
1802
|
-
Unless required by applicable law or agreed to in writing, software
|
|
1803
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1804
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1805
|
-
See the License for the specific language governing permissions and
|
|
1806
|
-
limitations under the License.
|
|
1807
|
-
*/
|
|
1578
|
+
return MissingToolsError;
|
|
1579
|
+
}(Error));
|
|
1808
1580
|
|
|
1809
1581
|
/**
|
|
1810
|
-
*
|
|
1582
|
+
* This error indicates errors during the execution of the pipeline
|
|
1811
1583
|
*
|
|
1812
|
-
* @
|
|
1813
|
-
* @returns @@@
|
|
1814
|
-
* @public exported from `@promptbook/utils`
|
|
1815
|
-
*/
|
|
1816
|
-
function removeDiacritics(input) {
|
|
1817
|
-
/*eslint no-control-regex: "off"*/
|
|
1818
|
-
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
1819
|
-
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
/**
|
|
1823
|
-
* TODO: [Ж] Variant for cyrillic (and in general non-latin) letters
|
|
1824
|
-
*/
|
|
1825
|
-
|
|
1826
|
-
/**
|
|
1827
|
-
* @@@
|
|
1828
|
-
*
|
|
1829
|
-
* @param text @@@
|
|
1830
|
-
* @returns @@@
|
|
1831
|
-
* @example 'hello-world'
|
|
1832
|
-
* @example 'i-love-promptbook'
|
|
1833
|
-
* @public exported from `@promptbook/utils`
|
|
1834
|
-
*/
|
|
1835
|
-
function normalizeToKebabCase(text) {
|
|
1836
|
-
var e_1, _a;
|
|
1837
|
-
text = removeDiacritics(text);
|
|
1838
|
-
var charType;
|
|
1839
|
-
var lastCharType = 'OTHER';
|
|
1840
|
-
var normalizedName = '';
|
|
1841
|
-
try {
|
|
1842
|
-
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
1843
|
-
var char = text_1_1.value;
|
|
1844
|
-
var normalizedChar = void 0;
|
|
1845
|
-
if (/^[a-z]$/.test(char)) {
|
|
1846
|
-
charType = 'LOWERCASE';
|
|
1847
|
-
normalizedChar = char;
|
|
1848
|
-
}
|
|
1849
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
1850
|
-
charType = 'UPPERCASE';
|
|
1851
|
-
normalizedChar = char.toLowerCase();
|
|
1852
|
-
}
|
|
1853
|
-
else if (/^[0-9]$/.test(char)) {
|
|
1854
|
-
charType = 'NUMBER';
|
|
1855
|
-
normalizedChar = char;
|
|
1856
|
-
}
|
|
1857
|
-
else {
|
|
1858
|
-
charType = 'OTHER';
|
|
1859
|
-
normalizedChar = '-';
|
|
1860
|
-
}
|
|
1861
|
-
if (charType !== lastCharType &&
|
|
1862
|
-
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
1863
|
-
!(lastCharType === 'NUMBER') &&
|
|
1864
|
-
!(charType === 'NUMBER')) {
|
|
1865
|
-
normalizedName += '-';
|
|
1866
|
-
}
|
|
1867
|
-
normalizedName += normalizedChar;
|
|
1868
|
-
lastCharType = charType;
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1872
|
-
finally {
|
|
1873
|
-
try {
|
|
1874
|
-
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
1875
|
-
}
|
|
1876
|
-
finally { if (e_1) throw e_1.error; }
|
|
1877
|
-
}
|
|
1878
|
-
normalizedName = normalizedName.split(/-+/g).join('-');
|
|
1879
|
-
normalizedName = normalizedName.split(/-?\/-?/g).join('/');
|
|
1880
|
-
normalizedName = normalizedName.replace(/^-/, '');
|
|
1881
|
-
normalizedName = normalizedName.replace(/-$/, '');
|
|
1882
|
-
return normalizedName;
|
|
1883
|
-
}
|
|
1884
|
-
/**
|
|
1885
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1886
|
-
*/
|
|
1887
|
-
|
|
1888
|
-
/**
|
|
1889
|
-
* Removes emojis from a string and fix whitespaces
|
|
1890
|
-
*
|
|
1891
|
-
* @param text with emojis
|
|
1892
|
-
* @returns text without emojis
|
|
1893
|
-
* @public exported from `@promptbook/utils`
|
|
1894
|
-
*/
|
|
1895
|
-
function removeEmojis(text) {
|
|
1896
|
-
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
1897
|
-
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
1898
|
-
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
1899
|
-
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
1900
|
-
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
1901
|
-
return text;
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
/**
|
|
1905
|
-
* Tests if given string is valid URL.
|
|
1906
|
-
*
|
|
1907
|
-
* Note: This does not check if the file exists only if the path is valid
|
|
1908
|
-
* @public exported from `@promptbook/utils`
|
|
1909
|
-
*/
|
|
1910
|
-
function isValidFilePath(filename) {
|
|
1911
|
-
if (typeof filename !== 'string') {
|
|
1912
|
-
return false;
|
|
1913
|
-
}
|
|
1914
|
-
var filenameSlashes = filename.split('\\').join('/');
|
|
1915
|
-
// Absolute Unix path: /hello.txt
|
|
1916
|
-
if (/^(\/)/i.test(filenameSlashes)) {
|
|
1917
|
-
return true;
|
|
1918
|
-
}
|
|
1919
|
-
// Absolute Windows path: /hello.txt
|
|
1920
|
-
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
1921
|
-
return true;
|
|
1922
|
-
}
|
|
1923
|
-
// Relative path: ./hello.txt
|
|
1924
|
-
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
1925
|
-
return true;
|
|
1926
|
-
}
|
|
1927
|
-
return false;
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
/**
|
|
1931
|
-
* @@@
|
|
1932
|
-
*
|
|
1933
|
-
* @param value @@@
|
|
1934
|
-
* @returns @@@
|
|
1935
|
-
* @example @@@
|
|
1936
|
-
* @public exported from `@promptbook/utils`
|
|
1937
|
-
*/
|
|
1938
|
-
function titleToName(value) {
|
|
1939
|
-
if (isValidUrl(value)) {
|
|
1940
|
-
value = value.replace(/^https?:\/\//, '');
|
|
1941
|
-
value = value.replace(/\.html$/, '');
|
|
1942
|
-
}
|
|
1943
|
-
else if (isValidFilePath(value)) {
|
|
1944
|
-
value = basename(value);
|
|
1945
|
-
// Note: Keeping extension in the name
|
|
1946
|
-
}
|
|
1947
|
-
value = value.split('/').join('-');
|
|
1948
|
-
value = removeEmojis(value);
|
|
1949
|
-
value = normalizeToKebabCase(value);
|
|
1950
|
-
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
1951
|
-
return value;
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
/**
|
|
1955
|
-
* This error type indicates that some tools are missing for pipeline execution or preparation
|
|
1956
|
-
*
|
|
1957
|
-
* @public exported from `@promptbook/core`
|
|
1958
|
-
*/
|
|
1959
|
-
var MissingToolsError = /** @class */ (function (_super) {
|
|
1960
|
-
__extends(MissingToolsError, _super);
|
|
1961
|
-
function MissingToolsError(message) {
|
|
1962
|
-
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: You have probbably forgot to provide some tools for pipeline execution or preparation\n\n "); })) || this;
|
|
1963
|
-
_this.name = 'MissingToolsError';
|
|
1964
|
-
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
1965
|
-
return _this;
|
|
1966
|
-
}
|
|
1967
|
-
return MissingToolsError;
|
|
1968
|
-
}(Error));
|
|
1969
|
-
|
|
1970
|
-
/**
|
|
1971
|
-
* This error indicates errors during the execution of the pipeline
|
|
1972
|
-
*
|
|
1973
|
-
* @public exported from `@promptbook/core`
|
|
1584
|
+
* @public exported from `@promptbook/core`
|
|
1974
1585
|
*/
|
|
1975
1586
|
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
1976
1587
|
__extends(PipelineExecutionError, _super);
|
|
@@ -2123,7 +1734,7 @@ var NotYetImplementedError = /** @class */ (function (_super) {
|
|
|
2123
1734
|
*
|
|
2124
1735
|
* @public exported from `@promptbook/core`
|
|
2125
1736
|
*/
|
|
2126
|
-
var
|
|
1737
|
+
var PROMPTBOOK_ERRORS = {
|
|
2127
1738
|
AbstractFormatError: AbstractFormatError,
|
|
2128
1739
|
CsvFormatError: CsvFormatError,
|
|
2129
1740
|
CollectionError: CollectionError,
|
|
@@ -2141,6 +1752,35 @@ var ERRORS = {
|
|
|
2141
1752
|
UnexpectedError: UnexpectedError,
|
|
2142
1753
|
// TODO: [🪑]> VersionMismatchError,
|
|
2143
1754
|
};
|
|
1755
|
+
/**
|
|
1756
|
+
* Index of all javascript errors
|
|
1757
|
+
*
|
|
1758
|
+
* @private for internal usage
|
|
1759
|
+
*/
|
|
1760
|
+
var COMMON_JAVASCRIPT_ERRORS = {
|
|
1761
|
+
Error: Error,
|
|
1762
|
+
EvalError: EvalError,
|
|
1763
|
+
RangeError: RangeError,
|
|
1764
|
+
ReferenceError: ReferenceError,
|
|
1765
|
+
SyntaxError: SyntaxError,
|
|
1766
|
+
TypeError: TypeError,
|
|
1767
|
+
URIError: URIError,
|
|
1768
|
+
AggregateError: AggregateError,
|
|
1769
|
+
/*
|
|
1770
|
+
Note: Not widely supported
|
|
1771
|
+
> InternalError,
|
|
1772
|
+
> ModuleError,
|
|
1773
|
+
> HeapError,
|
|
1774
|
+
> WebAssemblyCompileError,
|
|
1775
|
+
> WebAssemblyRuntimeError,
|
|
1776
|
+
*/
|
|
1777
|
+
};
|
|
1778
|
+
/**
|
|
1779
|
+
* Index of all errors
|
|
1780
|
+
*
|
|
1781
|
+
* @private for internal usage
|
|
1782
|
+
*/
|
|
1783
|
+
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
2144
1784
|
/**
|
|
2145
1785
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2146
1786
|
*/
|
|
@@ -2151,11 +1791,11 @@ var ERRORS = {
|
|
|
2151
1791
|
* @public exported from `@promptbook/utils`
|
|
2152
1792
|
*/
|
|
2153
1793
|
function deserializeError(error) {
|
|
2154
|
-
|
|
2155
|
-
|
|
1794
|
+
var ErrorClass = ALL_ERRORS[error.name];
|
|
1795
|
+
if (ErrorClass === undefined) {
|
|
1796
|
+
return new Error("".concat(error.name, ": ").concat(error.message));
|
|
2156
1797
|
}
|
|
2157
|
-
|
|
2158
|
-
return new CustomError(error.message);
|
|
1798
|
+
return new ErrorClass(error.message);
|
|
2159
1799
|
}
|
|
2160
1800
|
|
|
2161
1801
|
/**
|
|
@@ -2229,8 +1869,8 @@ function isPipelinePrepared(pipeline) {
|
|
|
2229
1869
|
*/
|
|
2230
1870
|
function serializeError(error) {
|
|
2231
1871
|
var name = error.name, message = error.message, stack = error.stack;
|
|
2232
|
-
if (!
|
|
2233
|
-
|
|
1872
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
1873
|
+
console.error(spaceTrim(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2234
1874
|
}
|
|
2235
1875
|
return {
|
|
2236
1876
|
name: name,
|
|
@@ -3071,148 +2711,471 @@ var $Register = /** @class */ (function () {
|
|
|
3071
2711
|
return $Register;
|
|
3072
2712
|
}());
|
|
3073
2713
|
|
|
3074
|
-
/**
|
|
3075
|
-
* @@@
|
|
3076
|
-
*
|
|
3077
|
-
* Note: `$` is used to indicate that this interacts with the global scope
|
|
3078
|
-
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
3079
|
-
* @public exported from `@promptbook/core`
|
|
3080
|
-
*/
|
|
3081
|
-
var $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
3082
|
-
/**
|
|
3083
|
-
* TODO: [®] DRY Register logic
|
|
3084
|
-
*/
|
|
2714
|
+
/**
|
|
2715
|
+
* @@@
|
|
2716
|
+
*
|
|
2717
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
2718
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
2719
|
+
* @public exported from `@promptbook/core`
|
|
2720
|
+
*/
|
|
2721
|
+
var $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
2722
|
+
/**
|
|
2723
|
+
* TODO: [®] DRY Register logic
|
|
2724
|
+
*/
|
|
2725
|
+
|
|
2726
|
+
/**
|
|
2727
|
+
* @@@
|
|
2728
|
+
*
|
|
2729
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
2730
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
2731
|
+
* @public exported from `@promptbook/core`
|
|
2732
|
+
*/
|
|
2733
|
+
var $scrapersRegister = new $Register('scraper_constructors');
|
|
2734
|
+
/**
|
|
2735
|
+
* TODO: [®] DRY Register logic
|
|
2736
|
+
*/
|
|
2737
|
+
|
|
2738
|
+
/**
|
|
2739
|
+
* Creates a message with all registered scrapers
|
|
2740
|
+
*
|
|
2741
|
+
* Note: This function is used to create a (error) message when there is no scraper for particular mime type
|
|
2742
|
+
*
|
|
2743
|
+
* @private internal function of `createScrapersFromConfiguration` and `createScrapersFromEnv`
|
|
2744
|
+
*/
|
|
2745
|
+
function $registeredScrapersMessage(availableScrapers) {
|
|
2746
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
2747
|
+
/**
|
|
2748
|
+
* Mixes registered scrapers from $scrapersMetadataRegister and $scrapersRegister
|
|
2749
|
+
*/
|
|
2750
|
+
var all = [];
|
|
2751
|
+
var _loop_1 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
|
|
2752
|
+
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
2753
|
+
return "continue";
|
|
2754
|
+
}
|
|
2755
|
+
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
2756
|
+
};
|
|
2757
|
+
try {
|
|
2758
|
+
for (var _d = __values($scrapersMetadataRegister.list()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
2759
|
+
var _f = _e.value, packageName = _f.packageName, className = _f.className, mimeTypes = _f.mimeTypes, documentationUrl = _f.documentationUrl, isAvilableInBrowser = _f.isAvilableInBrowser;
|
|
2760
|
+
_loop_1(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2764
|
+
finally {
|
|
2765
|
+
try {
|
|
2766
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
2767
|
+
}
|
|
2768
|
+
finally { if (e_1) throw e_1.error; }
|
|
2769
|
+
}
|
|
2770
|
+
var _loop_2 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
|
|
2771
|
+
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
2772
|
+
return "continue";
|
|
2773
|
+
}
|
|
2774
|
+
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
2775
|
+
};
|
|
2776
|
+
try {
|
|
2777
|
+
for (var _g = __values($scrapersRegister.list()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2778
|
+
var _j = _h.value, packageName = _j.packageName, className = _j.className, mimeTypes = _j.mimeTypes, documentationUrl = _j.documentationUrl, isAvilableInBrowser = _j.isAvilableInBrowser;
|
|
2779
|
+
_loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2783
|
+
finally {
|
|
2784
|
+
try {
|
|
2785
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
2786
|
+
}
|
|
2787
|
+
finally { if (e_2) throw e_2.error; }
|
|
2788
|
+
}
|
|
2789
|
+
try {
|
|
2790
|
+
for (var availableScrapers_1 = __values(availableScrapers), availableScrapers_1_1 = availableScrapers_1.next(); !availableScrapers_1_1.done; availableScrapers_1_1 = availableScrapers_1.next()) {
|
|
2791
|
+
var metadata_1 = availableScrapers_1_1.value.metadata;
|
|
2792
|
+
all.push(metadata_1);
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
2796
|
+
finally {
|
|
2797
|
+
try {
|
|
2798
|
+
if (availableScrapers_1_1 && !availableScrapers_1_1.done && (_c = availableScrapers_1.return)) _c.call(availableScrapers_1);
|
|
2799
|
+
}
|
|
2800
|
+
finally { if (e_3) throw e_3.error; }
|
|
2801
|
+
}
|
|
2802
|
+
var metadata = all.map(function (metadata) {
|
|
2803
|
+
var isMetadataAviailable = $scrapersMetadataRegister
|
|
2804
|
+
.list()
|
|
2805
|
+
.find(function (_a) {
|
|
2806
|
+
var packageName = _a.packageName, className = _a.className;
|
|
2807
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
2808
|
+
});
|
|
2809
|
+
var isInstalled = $scrapersRegister
|
|
2810
|
+
.list()
|
|
2811
|
+
.find(function (_a) {
|
|
2812
|
+
var packageName = _a.packageName, className = _a.className;
|
|
2813
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
2814
|
+
});
|
|
2815
|
+
var isAvilableInTools = availableScrapers.some(function (_a) {
|
|
2816
|
+
var _b = _a.metadata, packageName = _b.packageName, className = _b.className;
|
|
2817
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
2818
|
+
});
|
|
2819
|
+
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
|
|
2820
|
+
});
|
|
2821
|
+
if (metadata.length === 0) {
|
|
2822
|
+
return spaceTrim("\n **No scrapers are available**\n\n This is a unexpected behavior, you are probably using some broken version of Promptbook\n At least there should be available the metadata of the scrapers\n ");
|
|
2823
|
+
}
|
|
2824
|
+
return spaceTrim(function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
|
|
2825
|
+
.map(function (_a, i) {
|
|
2826
|
+
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
|
|
2827
|
+
var more = [];
|
|
2828
|
+
// TODO: [🧠] Maybe use `documentationUrl`
|
|
2829
|
+
if (isMetadataAviailable) {
|
|
2830
|
+
more.push("\u2B1C Metadata registered");
|
|
2831
|
+
} // not else
|
|
2832
|
+
if (isInstalled) {
|
|
2833
|
+
more.push("\uD83D\uDFE9 Installed");
|
|
2834
|
+
} // not else
|
|
2835
|
+
if (isAvilableInTools) {
|
|
2836
|
+
more.push("\uD83D\uDFE6 Available in tools");
|
|
2837
|
+
} // not else
|
|
2838
|
+
if (!isMetadataAviailable && isInstalled) {
|
|
2839
|
+
more.push("When no metadata registered but scraper is installed, it is an unexpected behavior");
|
|
2840
|
+
} // not else
|
|
2841
|
+
if (!isInstalled && isAvilableInTools) {
|
|
2842
|
+
more.push("When the scraper is not installed but available in tools, it is an unexpected compatibility behavior");
|
|
2843
|
+
} // not else
|
|
2844
|
+
if (!isAvilableInBrowser) {
|
|
2845
|
+
more.push("Not usable in browser");
|
|
2846
|
+
}
|
|
2847
|
+
var moreText = more.length === 0 ? '' : " *(".concat(more.join('; '), ")*");
|
|
2848
|
+
return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes
|
|
2849
|
+
.map(function (mimeType) { return "\"".concat(mimeType, "\""); })
|
|
2850
|
+
.join(', ')).concat(moreText);
|
|
2851
|
+
})
|
|
2852
|
+
.join('\n')), "\n\n Legend:\n - \u2B1C **Metadata registered** means that Promptbook knows about the scraper, it is similar to registration in some registry\n - \uD83D\uDFE9 **Installed** means that you have imported package with particular scraper\n - \uD83D\uDFE6 **Available in tools** means that you have passed scraper as dependency into prepare or execution process\n\n "); });
|
|
2853
|
+
}
|
|
2854
|
+
/**
|
|
2855
|
+
* TODO: [®] DRY Register logic
|
|
2856
|
+
*/
|
|
2857
|
+
|
|
2858
|
+
var defaultDiacriticsRemovalMap = [
|
|
2859
|
+
{
|
|
2860
|
+
base: 'A',
|
|
2861
|
+
letters: '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F',
|
|
2862
|
+
},
|
|
2863
|
+
{ base: 'AA', letters: '\uA732' },
|
|
2864
|
+
{ base: 'AE', letters: '\u00C6\u01FC\u01E2' },
|
|
2865
|
+
{ base: 'AO', letters: '\uA734' },
|
|
2866
|
+
{ base: 'AU', letters: '\uA736' },
|
|
2867
|
+
{ base: 'AV', letters: '\uA738\uA73A' },
|
|
2868
|
+
{ base: 'AY', letters: '\uA73C' },
|
|
2869
|
+
{
|
|
2870
|
+
base: 'B',
|
|
2871
|
+
letters: '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181',
|
|
2872
|
+
},
|
|
2873
|
+
{
|
|
2874
|
+
base: 'C',
|
|
2875
|
+
letters: '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E',
|
|
2876
|
+
},
|
|
2877
|
+
{
|
|
2878
|
+
base: 'D',
|
|
2879
|
+
letters: '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0',
|
|
2880
|
+
},
|
|
2881
|
+
{ base: 'DZ', letters: '\u01F1\u01C4' },
|
|
2882
|
+
{ base: 'Dz', letters: '\u01F2\u01C5' },
|
|
2883
|
+
{
|
|
2884
|
+
base: 'E',
|
|
2885
|
+
letters: '\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E',
|
|
2886
|
+
},
|
|
2887
|
+
{ base: 'F', letters: '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' },
|
|
2888
|
+
{
|
|
2889
|
+
base: 'G',
|
|
2890
|
+
letters: '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E',
|
|
2891
|
+
},
|
|
2892
|
+
{
|
|
2893
|
+
base: 'H',
|
|
2894
|
+
letters: '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D',
|
|
2895
|
+
},
|
|
2896
|
+
{
|
|
2897
|
+
base: 'I',
|
|
2898
|
+
letters: '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197',
|
|
2899
|
+
},
|
|
2900
|
+
{ base: 'J', letters: '\u004A\u24BF\uFF2A\u0134\u0248' },
|
|
2901
|
+
{
|
|
2902
|
+
base: 'K',
|
|
2903
|
+
letters: '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2',
|
|
2904
|
+
},
|
|
2905
|
+
{
|
|
2906
|
+
base: 'L',
|
|
2907
|
+
letters: '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780',
|
|
2908
|
+
},
|
|
2909
|
+
{ base: 'LJ', letters: '\u01C7' },
|
|
2910
|
+
{ base: 'Lj', letters: '\u01C8' },
|
|
2911
|
+
{ base: 'M', letters: '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' },
|
|
2912
|
+
{
|
|
2913
|
+
base: 'N',
|
|
2914
|
+
letters: '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4',
|
|
2915
|
+
},
|
|
2916
|
+
{ base: 'NJ', letters: '\u01CA' },
|
|
2917
|
+
{ base: 'Nj', letters: '\u01CB' },
|
|
2918
|
+
{
|
|
2919
|
+
base: 'O',
|
|
2920
|
+
letters: '\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C',
|
|
2921
|
+
},
|
|
2922
|
+
{ base: 'OI', letters: '\u01A2' },
|
|
2923
|
+
{ base: 'OO', letters: '\uA74E' },
|
|
2924
|
+
{ base: 'OU', letters: '\u0222' },
|
|
2925
|
+
{ base: 'OE', letters: '\u008C\u0152' },
|
|
2926
|
+
{ base: 'oe', letters: '\u009C\u0153' },
|
|
2927
|
+
{
|
|
2928
|
+
base: 'P',
|
|
2929
|
+
letters: '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754',
|
|
2930
|
+
},
|
|
2931
|
+
{ base: 'Q', letters: '\u0051\u24C6\uFF31\uA756\uA758\u024A' },
|
|
2932
|
+
{
|
|
2933
|
+
base: 'R',
|
|
2934
|
+
letters: '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782',
|
|
2935
|
+
},
|
|
2936
|
+
{
|
|
2937
|
+
base: 'S',
|
|
2938
|
+
letters: '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784',
|
|
2939
|
+
},
|
|
2940
|
+
{
|
|
2941
|
+
base: 'T',
|
|
2942
|
+
letters: '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786',
|
|
2943
|
+
},
|
|
2944
|
+
{ base: 'TZ', letters: '\uA728' },
|
|
2945
|
+
{
|
|
2946
|
+
base: 'U',
|
|
2947
|
+
letters: '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244',
|
|
2948
|
+
},
|
|
2949
|
+
{ base: 'V', letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' },
|
|
2950
|
+
{ base: 'VY', letters: '\uA760' },
|
|
2951
|
+
{
|
|
2952
|
+
base: 'W',
|
|
2953
|
+
letters: '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72',
|
|
2954
|
+
},
|
|
2955
|
+
{ base: 'X', letters: '\u0058\u24CD\uFF38\u1E8A\u1E8C' },
|
|
2956
|
+
{
|
|
2957
|
+
base: 'Y',
|
|
2958
|
+
letters: '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE',
|
|
2959
|
+
},
|
|
2960
|
+
{
|
|
2961
|
+
base: 'Z',
|
|
2962
|
+
letters: '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762',
|
|
2963
|
+
},
|
|
2964
|
+
{
|
|
2965
|
+
base: 'a',
|
|
2966
|
+
letters: '\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250',
|
|
2967
|
+
},
|
|
2968
|
+
{ base: 'aa', letters: '\uA733' },
|
|
2969
|
+
{ base: 'ae', letters: '\u00E6\u01FD\u01E3' },
|
|
2970
|
+
{ base: 'ao', letters: '\uA735' },
|
|
2971
|
+
{ base: 'au', letters: '\uA737' },
|
|
2972
|
+
{ base: 'av', letters: '\uA739\uA73B' },
|
|
2973
|
+
{ base: 'ay', letters: '\uA73D' },
|
|
2974
|
+
{
|
|
2975
|
+
base: 'b',
|
|
2976
|
+
letters: '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253',
|
|
2977
|
+
},
|
|
2978
|
+
{
|
|
2979
|
+
base: 'c',
|
|
2980
|
+
letters: '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184',
|
|
2981
|
+
},
|
|
2982
|
+
{
|
|
2983
|
+
base: 'd',
|
|
2984
|
+
letters: '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A',
|
|
2985
|
+
},
|
|
2986
|
+
{ base: 'dz', letters: '\u01F3\u01C6' },
|
|
2987
|
+
{
|
|
2988
|
+
base: 'e',
|
|
2989
|
+
letters: '\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD',
|
|
2990
|
+
},
|
|
2991
|
+
{ base: 'f', letters: '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' },
|
|
2992
|
+
{
|
|
2993
|
+
base: 'g',
|
|
2994
|
+
letters: '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F',
|
|
2995
|
+
},
|
|
2996
|
+
{
|
|
2997
|
+
base: 'h',
|
|
2998
|
+
letters: '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265',
|
|
2999
|
+
},
|
|
3000
|
+
{ base: 'hv', letters: '\u0195' },
|
|
3001
|
+
{
|
|
3002
|
+
base: 'i',
|
|
3003
|
+
letters: '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131',
|
|
3004
|
+
},
|
|
3005
|
+
{ base: 'j', letters: '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' },
|
|
3006
|
+
{
|
|
3007
|
+
base: 'k',
|
|
3008
|
+
letters: '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3',
|
|
3009
|
+
},
|
|
3010
|
+
{
|
|
3011
|
+
base: 'l',
|
|
3012
|
+
letters: '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747',
|
|
3013
|
+
},
|
|
3014
|
+
{ base: 'lj', letters: '\u01C9' },
|
|
3015
|
+
{ base: 'm', letters: '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' },
|
|
3016
|
+
{
|
|
3017
|
+
base: 'n',
|
|
3018
|
+
letters: '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5',
|
|
3019
|
+
},
|
|
3020
|
+
{ base: 'nj', letters: '\u01CC' },
|
|
3021
|
+
{
|
|
3022
|
+
base: 'o',
|
|
3023
|
+
letters: '\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275',
|
|
3024
|
+
},
|
|
3025
|
+
{ base: 'oi', letters: '\u01A3' },
|
|
3026
|
+
{ base: 'ou', letters: '\u0223' },
|
|
3027
|
+
{ base: 'oo', letters: '\uA74F' },
|
|
3028
|
+
{
|
|
3029
|
+
base: 'p',
|
|
3030
|
+
letters: '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755',
|
|
3031
|
+
},
|
|
3032
|
+
{ base: 'q', letters: '\u0071\u24E0\uFF51\u024B\uA757\uA759' },
|
|
3033
|
+
{
|
|
3034
|
+
base: 'r',
|
|
3035
|
+
letters: '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783',
|
|
3036
|
+
},
|
|
3037
|
+
{
|
|
3038
|
+
base: 's',
|
|
3039
|
+
letters: '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B',
|
|
3040
|
+
},
|
|
3041
|
+
{
|
|
3042
|
+
base: 't',
|
|
3043
|
+
letters: '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787',
|
|
3044
|
+
},
|
|
3045
|
+
{ base: 'tz', letters: '\uA729' },
|
|
3046
|
+
{
|
|
3047
|
+
base: 'u',
|
|
3048
|
+
letters: '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289',
|
|
3049
|
+
},
|
|
3050
|
+
{ base: 'v', letters: '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' },
|
|
3051
|
+
{ base: 'vy', letters: '\uA761' },
|
|
3052
|
+
{
|
|
3053
|
+
base: 'w',
|
|
3054
|
+
letters: '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73',
|
|
3055
|
+
},
|
|
3056
|
+
{ base: 'x', letters: '\u0078\u24E7\uFF58\u1E8B\u1E8D' },
|
|
3057
|
+
{
|
|
3058
|
+
base: 'y',
|
|
3059
|
+
letters: '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF',
|
|
3060
|
+
},
|
|
3061
|
+
{
|
|
3062
|
+
base: 'z',
|
|
3063
|
+
letters: '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763',
|
|
3064
|
+
},
|
|
3065
|
+
];
|
|
3066
|
+
/**
|
|
3067
|
+
* Map of letters from diacritic variant to diacritless variant
|
|
3068
|
+
* Contains lowercase and uppercase separatelly
|
|
3069
|
+
*
|
|
3070
|
+
* > "á" => "a"
|
|
3071
|
+
* > "ě" => "e"
|
|
3072
|
+
* > "Ă" => "A"
|
|
3073
|
+
* > ...
|
|
3074
|
+
*
|
|
3075
|
+
* @public exported from `@promptbook/utils`
|
|
3076
|
+
*/
|
|
3077
|
+
var DIACRITIC_VARIANTS_LETTERS = {};
|
|
3078
|
+
// tslint:disable-next-line: prefer-for-of
|
|
3079
|
+
for (var i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
3080
|
+
var letters = defaultDiacriticsRemovalMap[i].letters;
|
|
3081
|
+
// tslint:disable-next-line: prefer-for-of
|
|
3082
|
+
for (var j = 0; j < letters.length; j++) {
|
|
3083
|
+
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
// <- TODO: [🍓] Put to maker function to save execution time if not needed
|
|
3087
|
+
/*
|
|
3088
|
+
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
3089
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
3090
|
+
you may not use this file except in compliance with the License.
|
|
3091
|
+
You may obtain a copy of the License at
|
|
3092
|
+
|
|
3093
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
3094
|
+
|
|
3095
|
+
Unless required by applicable law or agreed to in writing, software
|
|
3096
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
3097
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3098
|
+
See the License for the specific language governing permissions and
|
|
3099
|
+
limitations under the License.
|
|
3100
|
+
*/
|
|
3085
3101
|
|
|
3086
3102
|
/**
|
|
3087
3103
|
* @@@
|
|
3088
3104
|
*
|
|
3089
|
-
*
|
|
3090
|
-
* @
|
|
3091
|
-
* @public exported from `@promptbook/
|
|
3105
|
+
* @param input @@@
|
|
3106
|
+
* @returns @@@
|
|
3107
|
+
* @public exported from `@promptbook/utils`
|
|
3092
3108
|
*/
|
|
3093
|
-
|
|
3109
|
+
function removeDiacritics(input) {
|
|
3110
|
+
/*eslint no-control-regex: "off"*/
|
|
3111
|
+
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
3112
|
+
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3094
3115
|
/**
|
|
3095
|
-
* TODO: [
|
|
3116
|
+
* TODO: [Ж] Variant for cyrillic (and in general non-latin) letters
|
|
3096
3117
|
*/
|
|
3097
3118
|
|
|
3098
3119
|
/**
|
|
3099
|
-
*
|
|
3100
|
-
*
|
|
3101
|
-
* Note: This function is used to create a (error) message when there is no scraper for particular mime type
|
|
3120
|
+
* @@@
|
|
3102
3121
|
*
|
|
3103
|
-
* @
|
|
3122
|
+
* @param text @@@
|
|
3123
|
+
* @returns @@@
|
|
3124
|
+
* @example 'hello-world'
|
|
3125
|
+
* @example 'i-love-promptbook'
|
|
3126
|
+
* @public exported from `@promptbook/utils`
|
|
3104
3127
|
*/
|
|
3105
|
-
function
|
|
3106
|
-
var e_1, _a
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
var
|
|
3111
|
-
var _loop_1 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
|
|
3112
|
-
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
3113
|
-
return "continue";
|
|
3114
|
-
}
|
|
3115
|
-
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
3116
|
-
};
|
|
3128
|
+
function normalizeToKebabCase(text) {
|
|
3129
|
+
var e_1, _a;
|
|
3130
|
+
text = removeDiacritics(text);
|
|
3131
|
+
var charType;
|
|
3132
|
+
var lastCharType = 'OTHER';
|
|
3133
|
+
var normalizedName = '';
|
|
3117
3134
|
try {
|
|
3118
|
-
for (var
|
|
3119
|
-
var
|
|
3120
|
-
|
|
3135
|
+
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
3136
|
+
var char = text_1_1.value;
|
|
3137
|
+
var normalizedChar = void 0;
|
|
3138
|
+
if (/^[a-z]$/.test(char)) {
|
|
3139
|
+
charType = 'LOWERCASE';
|
|
3140
|
+
normalizedChar = char;
|
|
3141
|
+
}
|
|
3142
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
3143
|
+
charType = 'UPPERCASE';
|
|
3144
|
+
normalizedChar = char.toLowerCase();
|
|
3145
|
+
}
|
|
3146
|
+
else if (/^[0-9]$/.test(char)) {
|
|
3147
|
+
charType = 'NUMBER';
|
|
3148
|
+
normalizedChar = char;
|
|
3149
|
+
}
|
|
3150
|
+
else {
|
|
3151
|
+
charType = 'OTHER';
|
|
3152
|
+
normalizedChar = '-';
|
|
3153
|
+
}
|
|
3154
|
+
if (charType !== lastCharType &&
|
|
3155
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
3156
|
+
!(lastCharType === 'NUMBER') &&
|
|
3157
|
+
!(charType === 'NUMBER')) {
|
|
3158
|
+
normalizedName += '-';
|
|
3159
|
+
}
|
|
3160
|
+
normalizedName += normalizedChar;
|
|
3161
|
+
lastCharType = charType;
|
|
3121
3162
|
}
|
|
3122
3163
|
}
|
|
3123
3164
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3124
3165
|
finally {
|
|
3125
3166
|
try {
|
|
3126
|
-
if (
|
|
3167
|
+
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
3127
3168
|
}
|
|
3128
3169
|
finally { if (e_1) throw e_1.error; }
|
|
3129
3170
|
}
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
};
|
|
3136
|
-
try {
|
|
3137
|
-
for (var _g = __values($scrapersRegister.list()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
3138
|
-
var _j = _h.value, packageName = _j.packageName, className = _j.className, mimeTypes = _j.mimeTypes, documentationUrl = _j.documentationUrl, isAvilableInBrowser = _j.isAvilableInBrowser;
|
|
3139
|
-
_loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
3140
|
-
}
|
|
3141
|
-
}
|
|
3142
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3143
|
-
finally {
|
|
3144
|
-
try {
|
|
3145
|
-
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
3146
|
-
}
|
|
3147
|
-
finally { if (e_2) throw e_2.error; }
|
|
3148
|
-
}
|
|
3149
|
-
try {
|
|
3150
|
-
for (var availableScrapers_1 = __values(availableScrapers), availableScrapers_1_1 = availableScrapers_1.next(); !availableScrapers_1_1.done; availableScrapers_1_1 = availableScrapers_1.next()) {
|
|
3151
|
-
var metadata_1 = availableScrapers_1_1.value.metadata;
|
|
3152
|
-
all.push(metadata_1);
|
|
3153
|
-
}
|
|
3154
|
-
}
|
|
3155
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
3156
|
-
finally {
|
|
3157
|
-
try {
|
|
3158
|
-
if (availableScrapers_1_1 && !availableScrapers_1_1.done && (_c = availableScrapers_1.return)) _c.call(availableScrapers_1);
|
|
3159
|
-
}
|
|
3160
|
-
finally { if (e_3) throw e_3.error; }
|
|
3161
|
-
}
|
|
3162
|
-
var metadata = all.map(function (metadata) {
|
|
3163
|
-
var isMetadataAviailable = $scrapersMetadataRegister
|
|
3164
|
-
.list()
|
|
3165
|
-
.find(function (_a) {
|
|
3166
|
-
var packageName = _a.packageName, className = _a.className;
|
|
3167
|
-
return metadata.packageName === packageName && metadata.className === className;
|
|
3168
|
-
});
|
|
3169
|
-
var isInstalled = $scrapersRegister
|
|
3170
|
-
.list()
|
|
3171
|
-
.find(function (_a) {
|
|
3172
|
-
var packageName = _a.packageName, className = _a.className;
|
|
3173
|
-
return metadata.packageName === packageName && metadata.className === className;
|
|
3174
|
-
});
|
|
3175
|
-
var isAvilableInTools = availableScrapers.some(function (_a) {
|
|
3176
|
-
var _b = _a.metadata, packageName = _b.packageName, className = _b.className;
|
|
3177
|
-
return metadata.packageName === packageName && metadata.className === className;
|
|
3178
|
-
});
|
|
3179
|
-
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
|
|
3180
|
-
});
|
|
3181
|
-
if (metadata.length === 0) {
|
|
3182
|
-
return spaceTrim("\n **No scrapers are available**\n\n This is a unexpected behavior, you are probably using some broken version of Promptbook\n At least there should be available the metadata of the scrapers\n ");
|
|
3183
|
-
}
|
|
3184
|
-
return spaceTrim(function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
|
|
3185
|
-
.map(function (_a, i) {
|
|
3186
|
-
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
|
|
3187
|
-
var more = [];
|
|
3188
|
-
// TODO: [🧠] Maybe use `documentationUrl`
|
|
3189
|
-
if (isMetadataAviailable) {
|
|
3190
|
-
more.push("\u2B1C Metadata registered");
|
|
3191
|
-
} // not else
|
|
3192
|
-
if (isInstalled) {
|
|
3193
|
-
more.push("\uD83D\uDFE9 Installed");
|
|
3194
|
-
} // not else
|
|
3195
|
-
if (isAvilableInTools) {
|
|
3196
|
-
more.push("\uD83D\uDFE6 Available in tools");
|
|
3197
|
-
} // not else
|
|
3198
|
-
if (!isMetadataAviailable && isInstalled) {
|
|
3199
|
-
more.push("When no metadata registered but scraper is installed, it is an unexpected behavior");
|
|
3200
|
-
} // not else
|
|
3201
|
-
if (!isInstalled && isAvilableInTools) {
|
|
3202
|
-
more.push("When the scraper is not installed but available in tools, it is an unexpected compatibility behavior");
|
|
3203
|
-
} // not else
|
|
3204
|
-
if (!isAvilableInBrowser) {
|
|
3205
|
-
more.push("Not usable in browser");
|
|
3206
|
-
}
|
|
3207
|
-
var moreText = more.length === 0 ? '' : " *(".concat(more.join('; '), ")*");
|
|
3208
|
-
return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes
|
|
3209
|
-
.map(function (mimeType) { return "\"".concat(mimeType, "\""); })
|
|
3210
|
-
.join(', ')).concat(moreText);
|
|
3211
|
-
})
|
|
3212
|
-
.join('\n')), "\n\n Legend:\n - \u2B1C **Metadata registered** means that Promptbook knows about the scraper, it is similar to registration in some registry\n - \uD83D\uDFE9 **Installed** means that you have imported package with particular scraper\n - \uD83D\uDFE6 **Available in tools** means that you have passed scraper as dependency into prepare or execution process\n\n "); });
|
|
3171
|
+
normalizedName = normalizedName.split(/-+/g).join('-');
|
|
3172
|
+
normalizedName = normalizedName.split(/-?\/-?/g).join('/');
|
|
3173
|
+
normalizedName = normalizedName.replace(/^-/, '');
|
|
3174
|
+
normalizedName = normalizedName.replace(/-$/, '');
|
|
3175
|
+
return normalizedName;
|
|
3213
3176
|
}
|
|
3214
3177
|
/**
|
|
3215
|
-
*
|
|
3178
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3216
3179
|
*/
|
|
3217
3180
|
|
|
3218
3181
|
/**
|
|
@@ -3291,6 +3254,32 @@ function isFileExisting(filename, fs) {
|
|
|
3291
3254
|
* TODO: [🖇] What about symlinks?
|
|
3292
3255
|
*/
|
|
3293
3256
|
|
|
3257
|
+
/**
|
|
3258
|
+
* Tests if given string is valid URL.
|
|
3259
|
+
*
|
|
3260
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
3261
|
+
* @public exported from `@promptbook/utils`
|
|
3262
|
+
*/
|
|
3263
|
+
function isValidFilePath(filename) {
|
|
3264
|
+
if (typeof filename !== 'string') {
|
|
3265
|
+
return false;
|
|
3266
|
+
}
|
|
3267
|
+
var filenameSlashes = filename.split('\\').join('/');
|
|
3268
|
+
// Absolute Unix path: /hello.txt
|
|
3269
|
+
if (/^(\/)/i.test(filenameSlashes)) {
|
|
3270
|
+
return true;
|
|
3271
|
+
}
|
|
3272
|
+
// Absolute Windows path: /hello.txt
|
|
3273
|
+
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
3274
|
+
return true;
|
|
3275
|
+
}
|
|
3276
|
+
// Relative path: ./hello.txt
|
|
3277
|
+
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
3278
|
+
return true;
|
|
3279
|
+
}
|
|
3280
|
+
return false;
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3294
3283
|
/**
|
|
3295
3284
|
* @@@
|
|
3296
3285
|
*
|
|
@@ -3752,9 +3741,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3752
3741
|
* @param script from which to extract the variables
|
|
3753
3742
|
* @returns the list of variable names
|
|
3754
3743
|
* @throws {ParseError} if the script is invalid
|
|
3755
|
-
* @public exported from `@promptbook/utils`
|
|
3744
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
3756
3745
|
*/
|
|
3757
|
-
function
|
|
3746
|
+
function extractVariablesFromScript(script) {
|
|
3758
3747
|
var variables = new Set();
|
|
3759
3748
|
script = "(()=>{".concat(script, "})()");
|
|
3760
3749
|
try {
|
|
@@ -3801,7 +3790,7 @@ function extractVariables(script) {
|
|
|
3801
3790
|
* @param task the task with used parameters
|
|
3802
3791
|
* @returns the set of parameter names
|
|
3803
3792
|
* @throws {ParseError} if the script is invalid
|
|
3804
|
-
* @public exported from `@promptbook/
|
|
3793
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
3805
3794
|
*/
|
|
3806
3795
|
function extractParameterNamesFromTask(task) {
|
|
3807
3796
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
@@ -3822,7 +3811,7 @@ function extractParameterNamesFromTask(task) {
|
|
|
3822
3811
|
}
|
|
3823
3812
|
if (taskType === 'SCRIPT_TASK') {
|
|
3824
3813
|
try {
|
|
3825
|
-
for (var _g = __values(
|
|
3814
|
+
for (var _g = __values(extractVariablesFromScript(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
3826
3815
|
var parameterName = _h.value;
|
|
3827
3816
|
parameterNames.add(parameterName);
|
|
3828
3817
|
}
|
|
@@ -5594,6 +5583,46 @@ function createPipelineExecutor(options) {
|
|
|
5594
5583
|
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
5595
5584
|
*/
|
|
5596
5585
|
|
|
5586
|
+
/**
|
|
5587
|
+
* Removes emojis from a string and fix whitespaces
|
|
5588
|
+
*
|
|
5589
|
+
* @param text with emojis
|
|
5590
|
+
* @returns text without emojis
|
|
5591
|
+
* @public exported from `@promptbook/utils`
|
|
5592
|
+
*/
|
|
5593
|
+
function removeEmojis(text) {
|
|
5594
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
5595
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
5596
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
5597
|
+
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
5598
|
+
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
5599
|
+
return text;
|
|
5600
|
+
}
|
|
5601
|
+
|
|
5602
|
+
/**
|
|
5603
|
+
* @@@
|
|
5604
|
+
*
|
|
5605
|
+
* @param value @@@
|
|
5606
|
+
* @returns @@@
|
|
5607
|
+
* @example @@@
|
|
5608
|
+
* @public exported from `@promptbook/utils`
|
|
5609
|
+
*/
|
|
5610
|
+
function titleToName(value) {
|
|
5611
|
+
if (isValidUrl(value)) {
|
|
5612
|
+
value = value.replace(/^https?:\/\//, '');
|
|
5613
|
+
value = value.replace(/\.html$/, '');
|
|
5614
|
+
}
|
|
5615
|
+
else if (isValidFilePath(value)) {
|
|
5616
|
+
value = basename(value);
|
|
5617
|
+
// Note: Keeping extension in the name
|
|
5618
|
+
}
|
|
5619
|
+
value = value.split('/').join('-');
|
|
5620
|
+
value = removeEmojis(value);
|
|
5621
|
+
value = normalizeToKebabCase(value);
|
|
5622
|
+
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
5623
|
+
return value;
|
|
5624
|
+
}
|
|
5625
|
+
|
|
5597
5626
|
/**
|
|
5598
5627
|
* Metadata of the scraper
|
|
5599
5628
|
*
|
|
@@ -5838,18 +5867,19 @@ function addAutoGeneratedSection(content, options) {
|
|
|
5838
5867
|
var warningLine = "<!-- ".concat(GENERATOR_WARNING, " -->");
|
|
5839
5868
|
var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
|
|
5840
5869
|
var sectionMatch = content.match(sectionRegex);
|
|
5870
|
+
var contentToInsert = spaceTrim$1(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); });
|
|
5841
5871
|
if (sectionMatch) {
|
|
5842
|
-
return content.replace(sectionRegex,
|
|
5872
|
+
return content.replace(sectionRegex, contentToInsert);
|
|
5843
5873
|
}
|
|
5874
|
+
// Note: Following is the case when the section is not found in the file so we add it there
|
|
5844
5875
|
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
5845
|
-
if (
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
5876
|
+
if (placeForSection !== null) {
|
|
5877
|
+
var _a = __read(placeForSection, 1), heading_1 = _a[0];
|
|
5878
|
+
return content.replace(heading_1, spaceTrim$1(function (block) { return "\n ".concat(block(contentToInsert), "\n \n ").concat(block(heading_1), "\n "); }));
|
|
5879
|
+
}
|
|
5880
|
+
console.warn("No place where to put the section <!--".concat(sectionName, "-->, using the end of the file"));
|
|
5881
|
+
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
5882
|
+
return spaceTrim$1(function (block) { return "\n ".concat(block(content), "\n \n ").concat(block(contentToInsert), "\n "); });
|
|
5853
5883
|
}
|
|
5854
5884
|
/**
|
|
5855
5885
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -6030,6 +6060,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
6030
6060
|
var e_1, _a;
|
|
6031
6061
|
var lines = markdown.split('\n');
|
|
6032
6062
|
var sections = [];
|
|
6063
|
+
// TODO: [🧽] DRY
|
|
6033
6064
|
var currentType = 'MARKDOWN';
|
|
6034
6065
|
var buffer = [];
|
|
6035
6066
|
var finishSection = function () {
|