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