@promptbook/pdf 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 +564 -535
- 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 +2 -2
- package/umd/index.umd.js +567 -538
- 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$1, { spaceTrim } 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
|
|
@@ -1396,415 +1396,26 @@ function createCollectionFromJson() {
|
|
|
1396
1396
|
return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
1397
1397
|
}
|
|
1398
1398
|
|
|
1399
|
-
var defaultDiacriticsRemovalMap = [
|
|
1400
|
-
{
|
|
1401
|
-
base: 'A',
|
|
1402
|
-
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',
|
|
1403
|
-
},
|
|
1404
|
-
{ base: 'AA', letters: '\uA732' },
|
|
1405
|
-
{ base: 'AE', letters: '\u00C6\u01FC\u01E2' },
|
|
1406
|
-
{ base: 'AO', letters: '\uA734' },
|
|
1407
|
-
{ base: 'AU', letters: '\uA736' },
|
|
1408
|
-
{ base: 'AV', letters: '\uA738\uA73A' },
|
|
1409
|
-
{ base: 'AY', letters: '\uA73C' },
|
|
1410
|
-
{
|
|
1411
|
-
base: 'B',
|
|
1412
|
-
letters: '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181',
|
|
1413
|
-
},
|
|
1414
|
-
{
|
|
1415
|
-
base: 'C',
|
|
1416
|
-
letters: '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E',
|
|
1417
|
-
},
|
|
1418
|
-
{
|
|
1419
|
-
base: 'D',
|
|
1420
|
-
letters: '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0',
|
|
1421
|
-
},
|
|
1422
|
-
{ base: 'DZ', letters: '\u01F1\u01C4' },
|
|
1423
|
-
{ base: 'Dz', letters: '\u01F2\u01C5' },
|
|
1424
|
-
{
|
|
1425
|
-
base: 'E',
|
|
1426
|
-
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',
|
|
1427
|
-
},
|
|
1428
|
-
{ base: 'F', letters: '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' },
|
|
1429
|
-
{
|
|
1430
|
-
base: 'G',
|
|
1431
|
-
letters: '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E',
|
|
1432
|
-
},
|
|
1433
|
-
{
|
|
1434
|
-
base: 'H',
|
|
1435
|
-
letters: '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D',
|
|
1436
|
-
},
|
|
1437
|
-
{
|
|
1438
|
-
base: 'I',
|
|
1439
|
-
letters: '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197',
|
|
1440
|
-
},
|
|
1441
|
-
{ base: 'J', letters: '\u004A\u24BF\uFF2A\u0134\u0248' },
|
|
1442
|
-
{
|
|
1443
|
-
base: 'K',
|
|
1444
|
-
letters: '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2',
|
|
1445
|
-
},
|
|
1446
|
-
{
|
|
1447
|
-
base: 'L',
|
|
1448
|
-
letters: '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780',
|
|
1449
|
-
},
|
|
1450
|
-
{ base: 'LJ', letters: '\u01C7' },
|
|
1451
|
-
{ base: 'Lj', letters: '\u01C8' },
|
|
1452
|
-
{ base: 'M', letters: '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' },
|
|
1453
|
-
{
|
|
1454
|
-
base: 'N',
|
|
1455
|
-
letters: '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4',
|
|
1456
|
-
},
|
|
1457
|
-
{ base: 'NJ', letters: '\u01CA' },
|
|
1458
|
-
{ base: 'Nj', letters: '\u01CB' },
|
|
1459
|
-
{
|
|
1460
|
-
base: 'O',
|
|
1461
|
-
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',
|
|
1462
|
-
},
|
|
1463
|
-
{ base: 'OI', letters: '\u01A2' },
|
|
1464
|
-
{ base: 'OO', letters: '\uA74E' },
|
|
1465
|
-
{ base: 'OU', letters: '\u0222' },
|
|
1466
|
-
{ base: 'OE', letters: '\u008C\u0152' },
|
|
1467
|
-
{ base: 'oe', letters: '\u009C\u0153' },
|
|
1468
|
-
{
|
|
1469
|
-
base: 'P',
|
|
1470
|
-
letters: '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754',
|
|
1471
|
-
},
|
|
1472
|
-
{ base: 'Q', letters: '\u0051\u24C6\uFF31\uA756\uA758\u024A' },
|
|
1473
|
-
{
|
|
1474
|
-
base: 'R',
|
|
1475
|
-
letters: '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782',
|
|
1476
|
-
},
|
|
1477
|
-
{
|
|
1478
|
-
base: 'S',
|
|
1479
|
-
letters: '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784',
|
|
1480
|
-
},
|
|
1481
|
-
{
|
|
1482
|
-
base: 'T',
|
|
1483
|
-
letters: '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786',
|
|
1484
|
-
},
|
|
1485
|
-
{ base: 'TZ', letters: '\uA728' },
|
|
1486
|
-
{
|
|
1487
|
-
base: 'U',
|
|
1488
|
-
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',
|
|
1489
|
-
},
|
|
1490
|
-
{ base: 'V', letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' },
|
|
1491
|
-
{ base: 'VY', letters: '\uA760' },
|
|
1492
|
-
{
|
|
1493
|
-
base: 'W',
|
|
1494
|
-
letters: '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72',
|
|
1495
|
-
},
|
|
1496
|
-
{ base: 'X', letters: '\u0058\u24CD\uFF38\u1E8A\u1E8C' },
|
|
1497
|
-
{
|
|
1498
|
-
base: 'Y',
|
|
1499
|
-
letters: '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE',
|
|
1500
|
-
},
|
|
1501
|
-
{
|
|
1502
|
-
base: 'Z',
|
|
1503
|
-
letters: '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762',
|
|
1504
|
-
},
|
|
1505
|
-
{
|
|
1506
|
-
base: 'a',
|
|
1507
|
-
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',
|
|
1508
|
-
},
|
|
1509
|
-
{ base: 'aa', letters: '\uA733' },
|
|
1510
|
-
{ base: 'ae', letters: '\u00E6\u01FD\u01E3' },
|
|
1511
|
-
{ base: 'ao', letters: '\uA735' },
|
|
1512
|
-
{ base: 'au', letters: '\uA737' },
|
|
1513
|
-
{ base: 'av', letters: '\uA739\uA73B' },
|
|
1514
|
-
{ base: 'ay', letters: '\uA73D' },
|
|
1515
|
-
{
|
|
1516
|
-
base: 'b',
|
|
1517
|
-
letters: '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253',
|
|
1518
|
-
},
|
|
1519
|
-
{
|
|
1520
|
-
base: 'c',
|
|
1521
|
-
letters: '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184',
|
|
1522
|
-
},
|
|
1523
|
-
{
|
|
1524
|
-
base: 'd',
|
|
1525
|
-
letters: '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A',
|
|
1526
|
-
},
|
|
1527
|
-
{ base: 'dz', letters: '\u01F3\u01C6' },
|
|
1528
|
-
{
|
|
1529
|
-
base: 'e',
|
|
1530
|
-
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',
|
|
1531
|
-
},
|
|
1532
|
-
{ base: 'f', letters: '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' },
|
|
1533
|
-
{
|
|
1534
|
-
base: 'g',
|
|
1535
|
-
letters: '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F',
|
|
1536
|
-
},
|
|
1537
|
-
{
|
|
1538
|
-
base: 'h',
|
|
1539
|
-
letters: '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265',
|
|
1540
|
-
},
|
|
1541
|
-
{ base: 'hv', letters: '\u0195' },
|
|
1542
|
-
{
|
|
1543
|
-
base: 'i',
|
|
1544
|
-
letters: '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131',
|
|
1545
|
-
},
|
|
1546
|
-
{ base: 'j', letters: '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' },
|
|
1547
|
-
{
|
|
1548
|
-
base: 'k',
|
|
1549
|
-
letters: '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3',
|
|
1550
|
-
},
|
|
1551
|
-
{
|
|
1552
|
-
base: 'l',
|
|
1553
|
-
letters: '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747',
|
|
1554
|
-
},
|
|
1555
|
-
{ base: 'lj', letters: '\u01C9' },
|
|
1556
|
-
{ base: 'm', letters: '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' },
|
|
1557
|
-
{
|
|
1558
|
-
base: 'n',
|
|
1559
|
-
letters: '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5',
|
|
1560
|
-
},
|
|
1561
|
-
{ base: 'nj', letters: '\u01CC' },
|
|
1562
|
-
{
|
|
1563
|
-
base: 'o',
|
|
1564
|
-
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',
|
|
1565
|
-
},
|
|
1566
|
-
{ base: 'oi', letters: '\u01A3' },
|
|
1567
|
-
{ base: 'ou', letters: '\u0223' },
|
|
1568
|
-
{ base: 'oo', letters: '\uA74F' },
|
|
1569
|
-
{
|
|
1570
|
-
base: 'p',
|
|
1571
|
-
letters: '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755',
|
|
1572
|
-
},
|
|
1573
|
-
{ base: 'q', letters: '\u0071\u24E0\uFF51\u024B\uA757\uA759' },
|
|
1574
|
-
{
|
|
1575
|
-
base: 'r',
|
|
1576
|
-
letters: '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783',
|
|
1577
|
-
},
|
|
1578
|
-
{
|
|
1579
|
-
base: 's',
|
|
1580
|
-
letters: '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B',
|
|
1581
|
-
},
|
|
1582
|
-
{
|
|
1583
|
-
base: 't',
|
|
1584
|
-
letters: '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787',
|
|
1585
|
-
},
|
|
1586
|
-
{ base: 'tz', letters: '\uA729' },
|
|
1587
|
-
{
|
|
1588
|
-
base: 'u',
|
|
1589
|
-
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',
|
|
1590
|
-
},
|
|
1591
|
-
{ base: 'v', letters: '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' },
|
|
1592
|
-
{ base: 'vy', letters: '\uA761' },
|
|
1593
|
-
{
|
|
1594
|
-
base: 'w',
|
|
1595
|
-
letters: '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73',
|
|
1596
|
-
},
|
|
1597
|
-
{ base: 'x', letters: '\u0078\u24E7\uFF58\u1E8B\u1E8D' },
|
|
1598
|
-
{
|
|
1599
|
-
base: 'y',
|
|
1600
|
-
letters: '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF',
|
|
1601
|
-
},
|
|
1602
|
-
{
|
|
1603
|
-
base: 'z',
|
|
1604
|
-
letters: '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763',
|
|
1605
|
-
},
|
|
1606
|
-
];
|
|
1607
1399
|
/**
|
|
1608
|
-
*
|
|
1609
|
-
* Contains lowercase and uppercase separatelly
|
|
1610
|
-
*
|
|
1611
|
-
* > "á" => "a"
|
|
1612
|
-
* > "ě" => "e"
|
|
1613
|
-
* > "Ă" => "A"
|
|
1614
|
-
* > ...
|
|
1400
|
+
* This error type indicates that some tools are missing for pipeline execution or preparation
|
|
1615
1401
|
*
|
|
1616
|
-
* @public exported from `@promptbook/
|
|
1402
|
+
* @public exported from `@promptbook/core`
|
|
1617
1403
|
*/
|
|
1618
|
-
var
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1404
|
+
var MissingToolsError = /** @class */ (function (_super) {
|
|
1405
|
+
__extends(MissingToolsError, _super);
|
|
1406
|
+
function MissingToolsError(message) {
|
|
1407
|
+
var _this = _super.call(this, 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;
|
|
1408
|
+
_this.name = 'MissingToolsError';
|
|
1409
|
+
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
1410
|
+
return _this;
|
|
1625
1411
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
/*
|
|
1629
|
-
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
1630
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1631
|
-
you may not use this file except in compliance with the License.
|
|
1632
|
-
You may obtain a copy of the License at
|
|
1633
|
-
|
|
1634
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
1635
|
-
|
|
1636
|
-
Unless required by applicable law or agreed to in writing, software
|
|
1637
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1638
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1639
|
-
See the License for the specific language governing permissions and
|
|
1640
|
-
limitations under the License.
|
|
1641
|
-
*/
|
|
1412
|
+
return MissingToolsError;
|
|
1413
|
+
}(Error));
|
|
1642
1414
|
|
|
1643
1415
|
/**
|
|
1644
|
-
*
|
|
1416
|
+
* This error indicates errors during the execution of the pipeline
|
|
1645
1417
|
*
|
|
1646
|
-
* @
|
|
1647
|
-
* @returns @@@
|
|
1648
|
-
* @public exported from `@promptbook/utils`
|
|
1649
|
-
*/
|
|
1650
|
-
function removeDiacritics(input) {
|
|
1651
|
-
/*eslint no-control-regex: "off"*/
|
|
1652
|
-
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
1653
|
-
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
1654
|
-
});
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* TODO: [Ж] Variant for cyrillic (and in general non-latin) letters
|
|
1658
|
-
*/
|
|
1659
|
-
|
|
1660
|
-
/**
|
|
1661
|
-
* @@@
|
|
1662
|
-
*
|
|
1663
|
-
* @param text @@@
|
|
1664
|
-
* @returns @@@
|
|
1665
|
-
* @example 'hello-world'
|
|
1666
|
-
* @example 'i-love-promptbook'
|
|
1667
|
-
* @public exported from `@promptbook/utils`
|
|
1668
|
-
*/
|
|
1669
|
-
function normalizeToKebabCase(text) {
|
|
1670
|
-
var e_1, _a;
|
|
1671
|
-
text = removeDiacritics(text);
|
|
1672
|
-
var charType;
|
|
1673
|
-
var lastCharType = 'OTHER';
|
|
1674
|
-
var normalizedName = '';
|
|
1675
|
-
try {
|
|
1676
|
-
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
1677
|
-
var char = text_1_1.value;
|
|
1678
|
-
var normalizedChar = void 0;
|
|
1679
|
-
if (/^[a-z]$/.test(char)) {
|
|
1680
|
-
charType = 'LOWERCASE';
|
|
1681
|
-
normalizedChar = char;
|
|
1682
|
-
}
|
|
1683
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
1684
|
-
charType = 'UPPERCASE';
|
|
1685
|
-
normalizedChar = char.toLowerCase();
|
|
1686
|
-
}
|
|
1687
|
-
else if (/^[0-9]$/.test(char)) {
|
|
1688
|
-
charType = 'NUMBER';
|
|
1689
|
-
normalizedChar = char;
|
|
1690
|
-
}
|
|
1691
|
-
else {
|
|
1692
|
-
charType = 'OTHER';
|
|
1693
|
-
normalizedChar = '-';
|
|
1694
|
-
}
|
|
1695
|
-
if (charType !== lastCharType &&
|
|
1696
|
-
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
1697
|
-
!(lastCharType === 'NUMBER') &&
|
|
1698
|
-
!(charType === 'NUMBER')) {
|
|
1699
|
-
normalizedName += '-';
|
|
1700
|
-
}
|
|
1701
|
-
normalizedName += normalizedChar;
|
|
1702
|
-
lastCharType = charType;
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1706
|
-
finally {
|
|
1707
|
-
try {
|
|
1708
|
-
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
1709
|
-
}
|
|
1710
|
-
finally { if (e_1) throw e_1.error; }
|
|
1711
|
-
}
|
|
1712
|
-
normalizedName = normalizedName.split(/-+/g).join('-');
|
|
1713
|
-
normalizedName = normalizedName.split(/-?\/-?/g).join('/');
|
|
1714
|
-
normalizedName = normalizedName.replace(/^-/, '');
|
|
1715
|
-
normalizedName = normalizedName.replace(/-$/, '');
|
|
1716
|
-
return normalizedName;
|
|
1717
|
-
}
|
|
1718
|
-
/**
|
|
1719
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1720
|
-
*/
|
|
1721
|
-
|
|
1722
|
-
/**
|
|
1723
|
-
* Removes emojis from a string and fix whitespaces
|
|
1724
|
-
*
|
|
1725
|
-
* @param text with emojis
|
|
1726
|
-
* @returns text without emojis
|
|
1727
|
-
* @public exported from `@promptbook/utils`
|
|
1728
|
-
*/
|
|
1729
|
-
function removeEmojis(text) {
|
|
1730
|
-
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
1731
|
-
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
1732
|
-
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
1733
|
-
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
1734
|
-
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
1735
|
-
return text;
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
/**
|
|
1739
|
-
* Tests if given string is valid URL.
|
|
1740
|
-
*
|
|
1741
|
-
* Note: This does not check if the file exists only if the path is valid
|
|
1742
|
-
* @public exported from `@promptbook/utils`
|
|
1743
|
-
*/
|
|
1744
|
-
function isValidFilePath(filename) {
|
|
1745
|
-
if (typeof filename !== 'string') {
|
|
1746
|
-
return false;
|
|
1747
|
-
}
|
|
1748
|
-
var filenameSlashes = filename.split('\\').join('/');
|
|
1749
|
-
// Absolute Unix path: /hello.txt
|
|
1750
|
-
if (/^(\/)/i.test(filenameSlashes)) {
|
|
1751
|
-
return true;
|
|
1752
|
-
}
|
|
1753
|
-
// Absolute Windows path: /hello.txt
|
|
1754
|
-
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
1755
|
-
return true;
|
|
1756
|
-
}
|
|
1757
|
-
// Relative path: ./hello.txt
|
|
1758
|
-
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
1759
|
-
return true;
|
|
1760
|
-
}
|
|
1761
|
-
return false;
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
/**
|
|
1765
|
-
* @@@
|
|
1766
|
-
*
|
|
1767
|
-
* @param value @@@
|
|
1768
|
-
* @returns @@@
|
|
1769
|
-
* @example @@@
|
|
1770
|
-
* @public exported from `@promptbook/utils`
|
|
1771
|
-
*/
|
|
1772
|
-
function titleToName(value) {
|
|
1773
|
-
if (isValidUrl(value)) {
|
|
1774
|
-
value = value.replace(/^https?:\/\//, '');
|
|
1775
|
-
value = value.replace(/\.html$/, '');
|
|
1776
|
-
}
|
|
1777
|
-
else if (isValidFilePath(value)) {
|
|
1778
|
-
value = basename(value);
|
|
1779
|
-
// Note: Keeping extension in the name
|
|
1780
|
-
}
|
|
1781
|
-
value = value.split('/').join('-');
|
|
1782
|
-
value = removeEmojis(value);
|
|
1783
|
-
value = normalizeToKebabCase(value);
|
|
1784
|
-
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
1785
|
-
return value;
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
/**
|
|
1789
|
-
* This error type indicates that some tools are missing for pipeline execution or preparation
|
|
1790
|
-
*
|
|
1791
|
-
* @public exported from `@promptbook/core`
|
|
1792
|
-
*/
|
|
1793
|
-
var MissingToolsError = /** @class */ (function (_super) {
|
|
1794
|
-
__extends(MissingToolsError, _super);
|
|
1795
|
-
function MissingToolsError(message) {
|
|
1796
|
-
var _this = _super.call(this, 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;
|
|
1797
|
-
_this.name = 'MissingToolsError';
|
|
1798
|
-
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
1799
|
-
return _this;
|
|
1800
|
-
}
|
|
1801
|
-
return MissingToolsError;
|
|
1802
|
-
}(Error));
|
|
1803
|
-
|
|
1804
|
-
/**
|
|
1805
|
-
* This error indicates errors during the execution of the pipeline
|
|
1806
|
-
*
|
|
1807
|
-
* @public exported from `@promptbook/core`
|
|
1418
|
+
* @public exported from `@promptbook/core`
|
|
1808
1419
|
*/
|
|
1809
1420
|
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
1810
1421
|
__extends(PipelineExecutionError, _super);
|
|
@@ -1941,7 +1552,7 @@ var LimitReachedError = /** @class */ (function (_super) {
|
|
|
1941
1552
|
*
|
|
1942
1553
|
* @public exported from `@promptbook/core`
|
|
1943
1554
|
*/
|
|
1944
|
-
var
|
|
1555
|
+
var PROMPTBOOK_ERRORS = {
|
|
1945
1556
|
AbstractFormatError: AbstractFormatError,
|
|
1946
1557
|
CsvFormatError: CsvFormatError,
|
|
1947
1558
|
CollectionError: CollectionError,
|
|
@@ -1959,6 +1570,35 @@ var ERRORS = {
|
|
|
1959
1570
|
UnexpectedError: UnexpectedError,
|
|
1960
1571
|
// TODO: [🪑]> VersionMismatchError,
|
|
1961
1572
|
};
|
|
1573
|
+
/**
|
|
1574
|
+
* Index of all javascript errors
|
|
1575
|
+
*
|
|
1576
|
+
* @private for internal usage
|
|
1577
|
+
*/
|
|
1578
|
+
var COMMON_JAVASCRIPT_ERRORS = {
|
|
1579
|
+
Error: Error,
|
|
1580
|
+
EvalError: EvalError,
|
|
1581
|
+
RangeError: RangeError,
|
|
1582
|
+
ReferenceError: ReferenceError,
|
|
1583
|
+
SyntaxError: SyntaxError,
|
|
1584
|
+
TypeError: TypeError,
|
|
1585
|
+
URIError: URIError,
|
|
1586
|
+
AggregateError: AggregateError,
|
|
1587
|
+
/*
|
|
1588
|
+
Note: Not widely supported
|
|
1589
|
+
> InternalError,
|
|
1590
|
+
> ModuleError,
|
|
1591
|
+
> HeapError,
|
|
1592
|
+
> WebAssemblyCompileError,
|
|
1593
|
+
> WebAssemblyRuntimeError,
|
|
1594
|
+
*/
|
|
1595
|
+
};
|
|
1596
|
+
/**
|
|
1597
|
+
* Index of all errors
|
|
1598
|
+
*
|
|
1599
|
+
* @private for internal usage
|
|
1600
|
+
*/
|
|
1601
|
+
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
1962
1602
|
/**
|
|
1963
1603
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1964
1604
|
*/
|
|
@@ -1969,11 +1609,11 @@ var ERRORS = {
|
|
|
1969
1609
|
* @public exported from `@promptbook/utils`
|
|
1970
1610
|
*/
|
|
1971
1611
|
function deserializeError(error) {
|
|
1972
|
-
|
|
1973
|
-
|
|
1612
|
+
var ErrorClass = ALL_ERRORS[error.name];
|
|
1613
|
+
if (ErrorClass === undefined) {
|
|
1614
|
+
return new Error("".concat(error.name, ": ").concat(error.message));
|
|
1974
1615
|
}
|
|
1975
|
-
|
|
1976
|
-
return new CustomError(error.message);
|
|
1616
|
+
return new ErrorClass(error.message);
|
|
1977
1617
|
}
|
|
1978
1618
|
|
|
1979
1619
|
/**
|
|
@@ -2047,8 +1687,8 @@ function isPipelinePrepared(pipeline) {
|
|
|
2047
1687
|
*/
|
|
2048
1688
|
function serializeError(error) {
|
|
2049
1689
|
var name = error.name, message = error.message, stack = error.stack;
|
|
2050
|
-
if (!
|
|
2051
|
-
|
|
1690
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
1691
|
+
console.error(spaceTrim$1(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2052
1692
|
}
|
|
2053
1693
|
return {
|
|
2054
1694
|
name: name,
|
|
@@ -2889,148 +2529,471 @@ var $Register = /** @class */ (function () {
|
|
|
2889
2529
|
return $Register;
|
|
2890
2530
|
}());
|
|
2891
2531
|
|
|
2892
|
-
/**
|
|
2893
|
-
* @@@
|
|
2894
|
-
*
|
|
2895
|
-
* Note: `$` is used to indicate that this interacts with the global scope
|
|
2896
|
-
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
2897
|
-
* @public exported from `@promptbook/core`
|
|
2898
|
-
*/
|
|
2899
|
-
var $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
2900
|
-
/**
|
|
2901
|
-
* TODO: [®] DRY Register logic
|
|
2902
|
-
*/
|
|
2532
|
+
/**
|
|
2533
|
+
* @@@
|
|
2534
|
+
*
|
|
2535
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
2536
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
2537
|
+
* @public exported from `@promptbook/core`
|
|
2538
|
+
*/
|
|
2539
|
+
var $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
2540
|
+
/**
|
|
2541
|
+
* TODO: [®] DRY Register logic
|
|
2542
|
+
*/
|
|
2543
|
+
|
|
2544
|
+
/**
|
|
2545
|
+
* @@@
|
|
2546
|
+
*
|
|
2547
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
2548
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
2549
|
+
* @public exported from `@promptbook/core`
|
|
2550
|
+
*/
|
|
2551
|
+
var $scrapersRegister = new $Register('scraper_constructors');
|
|
2552
|
+
/**
|
|
2553
|
+
* TODO: [®] DRY Register logic
|
|
2554
|
+
*/
|
|
2555
|
+
|
|
2556
|
+
/**
|
|
2557
|
+
* Creates a message with all registered scrapers
|
|
2558
|
+
*
|
|
2559
|
+
* Note: This function is used to create a (error) message when there is no scraper for particular mime type
|
|
2560
|
+
*
|
|
2561
|
+
* @private internal function of `createScrapersFromConfiguration` and `createScrapersFromEnv`
|
|
2562
|
+
*/
|
|
2563
|
+
function $registeredScrapersMessage(availableScrapers) {
|
|
2564
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
2565
|
+
/**
|
|
2566
|
+
* Mixes registered scrapers from $scrapersMetadataRegister and $scrapersRegister
|
|
2567
|
+
*/
|
|
2568
|
+
var all = [];
|
|
2569
|
+
var _loop_1 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
|
|
2570
|
+
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
2571
|
+
return "continue";
|
|
2572
|
+
}
|
|
2573
|
+
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
2574
|
+
};
|
|
2575
|
+
try {
|
|
2576
|
+
for (var _d = __values($scrapersMetadataRegister.list()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
2577
|
+
var _f = _e.value, packageName = _f.packageName, className = _f.className, mimeTypes = _f.mimeTypes, documentationUrl = _f.documentationUrl, isAvilableInBrowser = _f.isAvilableInBrowser;
|
|
2578
|
+
_loop_1(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2582
|
+
finally {
|
|
2583
|
+
try {
|
|
2584
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
2585
|
+
}
|
|
2586
|
+
finally { if (e_1) throw e_1.error; }
|
|
2587
|
+
}
|
|
2588
|
+
var _loop_2 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
|
|
2589
|
+
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
2590
|
+
return "continue";
|
|
2591
|
+
}
|
|
2592
|
+
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
2593
|
+
};
|
|
2594
|
+
try {
|
|
2595
|
+
for (var _g = __values($scrapersRegister.list()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2596
|
+
var _j = _h.value, packageName = _j.packageName, className = _j.className, mimeTypes = _j.mimeTypes, documentationUrl = _j.documentationUrl, isAvilableInBrowser = _j.isAvilableInBrowser;
|
|
2597
|
+
_loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2601
|
+
finally {
|
|
2602
|
+
try {
|
|
2603
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
2604
|
+
}
|
|
2605
|
+
finally { if (e_2) throw e_2.error; }
|
|
2606
|
+
}
|
|
2607
|
+
try {
|
|
2608
|
+
for (var availableScrapers_1 = __values(availableScrapers), availableScrapers_1_1 = availableScrapers_1.next(); !availableScrapers_1_1.done; availableScrapers_1_1 = availableScrapers_1.next()) {
|
|
2609
|
+
var metadata_1 = availableScrapers_1_1.value.metadata;
|
|
2610
|
+
all.push(metadata_1);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
2614
|
+
finally {
|
|
2615
|
+
try {
|
|
2616
|
+
if (availableScrapers_1_1 && !availableScrapers_1_1.done && (_c = availableScrapers_1.return)) _c.call(availableScrapers_1);
|
|
2617
|
+
}
|
|
2618
|
+
finally { if (e_3) throw e_3.error; }
|
|
2619
|
+
}
|
|
2620
|
+
var metadata = all.map(function (metadata) {
|
|
2621
|
+
var isMetadataAviailable = $scrapersMetadataRegister
|
|
2622
|
+
.list()
|
|
2623
|
+
.find(function (_a) {
|
|
2624
|
+
var packageName = _a.packageName, className = _a.className;
|
|
2625
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
2626
|
+
});
|
|
2627
|
+
var isInstalled = $scrapersRegister
|
|
2628
|
+
.list()
|
|
2629
|
+
.find(function (_a) {
|
|
2630
|
+
var packageName = _a.packageName, className = _a.className;
|
|
2631
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
2632
|
+
});
|
|
2633
|
+
var isAvilableInTools = availableScrapers.some(function (_a) {
|
|
2634
|
+
var _b = _a.metadata, packageName = _b.packageName, className = _b.className;
|
|
2635
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
2636
|
+
});
|
|
2637
|
+
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
|
|
2638
|
+
});
|
|
2639
|
+
if (metadata.length === 0) {
|
|
2640
|
+
return spaceTrim$1("\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 ");
|
|
2641
|
+
}
|
|
2642
|
+
return spaceTrim$1(function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
|
|
2643
|
+
.map(function (_a, i) {
|
|
2644
|
+
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
|
|
2645
|
+
var more = [];
|
|
2646
|
+
// TODO: [🧠] Maybe use `documentationUrl`
|
|
2647
|
+
if (isMetadataAviailable) {
|
|
2648
|
+
more.push("\u2B1C Metadata registered");
|
|
2649
|
+
} // not else
|
|
2650
|
+
if (isInstalled) {
|
|
2651
|
+
more.push("\uD83D\uDFE9 Installed");
|
|
2652
|
+
} // not else
|
|
2653
|
+
if (isAvilableInTools) {
|
|
2654
|
+
more.push("\uD83D\uDFE6 Available in tools");
|
|
2655
|
+
} // not else
|
|
2656
|
+
if (!isMetadataAviailable && isInstalled) {
|
|
2657
|
+
more.push("When no metadata registered but scraper is installed, it is an unexpected behavior");
|
|
2658
|
+
} // not else
|
|
2659
|
+
if (!isInstalled && isAvilableInTools) {
|
|
2660
|
+
more.push("When the scraper is not installed but available in tools, it is an unexpected compatibility behavior");
|
|
2661
|
+
} // not else
|
|
2662
|
+
if (!isAvilableInBrowser) {
|
|
2663
|
+
more.push("Not usable in browser");
|
|
2664
|
+
}
|
|
2665
|
+
var moreText = more.length === 0 ? '' : " *(".concat(more.join('; '), ")*");
|
|
2666
|
+
return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes
|
|
2667
|
+
.map(function (mimeType) { return "\"".concat(mimeType, "\""); })
|
|
2668
|
+
.join(', ')).concat(moreText);
|
|
2669
|
+
})
|
|
2670
|
+
.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 "); });
|
|
2671
|
+
}
|
|
2672
|
+
/**
|
|
2673
|
+
* TODO: [®] DRY Register logic
|
|
2674
|
+
*/
|
|
2675
|
+
|
|
2676
|
+
var defaultDiacriticsRemovalMap = [
|
|
2677
|
+
{
|
|
2678
|
+
base: 'A',
|
|
2679
|
+
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',
|
|
2680
|
+
},
|
|
2681
|
+
{ base: 'AA', letters: '\uA732' },
|
|
2682
|
+
{ base: 'AE', letters: '\u00C6\u01FC\u01E2' },
|
|
2683
|
+
{ base: 'AO', letters: '\uA734' },
|
|
2684
|
+
{ base: 'AU', letters: '\uA736' },
|
|
2685
|
+
{ base: 'AV', letters: '\uA738\uA73A' },
|
|
2686
|
+
{ base: 'AY', letters: '\uA73C' },
|
|
2687
|
+
{
|
|
2688
|
+
base: 'B',
|
|
2689
|
+
letters: '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181',
|
|
2690
|
+
},
|
|
2691
|
+
{
|
|
2692
|
+
base: 'C',
|
|
2693
|
+
letters: '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E',
|
|
2694
|
+
},
|
|
2695
|
+
{
|
|
2696
|
+
base: 'D',
|
|
2697
|
+
letters: '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0',
|
|
2698
|
+
},
|
|
2699
|
+
{ base: 'DZ', letters: '\u01F1\u01C4' },
|
|
2700
|
+
{ base: 'Dz', letters: '\u01F2\u01C5' },
|
|
2701
|
+
{
|
|
2702
|
+
base: 'E',
|
|
2703
|
+
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',
|
|
2704
|
+
},
|
|
2705
|
+
{ base: 'F', letters: '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' },
|
|
2706
|
+
{
|
|
2707
|
+
base: 'G',
|
|
2708
|
+
letters: '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E',
|
|
2709
|
+
},
|
|
2710
|
+
{
|
|
2711
|
+
base: 'H',
|
|
2712
|
+
letters: '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D',
|
|
2713
|
+
},
|
|
2714
|
+
{
|
|
2715
|
+
base: 'I',
|
|
2716
|
+
letters: '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197',
|
|
2717
|
+
},
|
|
2718
|
+
{ base: 'J', letters: '\u004A\u24BF\uFF2A\u0134\u0248' },
|
|
2719
|
+
{
|
|
2720
|
+
base: 'K',
|
|
2721
|
+
letters: '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2',
|
|
2722
|
+
},
|
|
2723
|
+
{
|
|
2724
|
+
base: 'L',
|
|
2725
|
+
letters: '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780',
|
|
2726
|
+
},
|
|
2727
|
+
{ base: 'LJ', letters: '\u01C7' },
|
|
2728
|
+
{ base: 'Lj', letters: '\u01C8' },
|
|
2729
|
+
{ base: 'M', letters: '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' },
|
|
2730
|
+
{
|
|
2731
|
+
base: 'N',
|
|
2732
|
+
letters: '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4',
|
|
2733
|
+
},
|
|
2734
|
+
{ base: 'NJ', letters: '\u01CA' },
|
|
2735
|
+
{ base: 'Nj', letters: '\u01CB' },
|
|
2736
|
+
{
|
|
2737
|
+
base: 'O',
|
|
2738
|
+
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',
|
|
2739
|
+
},
|
|
2740
|
+
{ base: 'OI', letters: '\u01A2' },
|
|
2741
|
+
{ base: 'OO', letters: '\uA74E' },
|
|
2742
|
+
{ base: 'OU', letters: '\u0222' },
|
|
2743
|
+
{ base: 'OE', letters: '\u008C\u0152' },
|
|
2744
|
+
{ base: 'oe', letters: '\u009C\u0153' },
|
|
2745
|
+
{
|
|
2746
|
+
base: 'P',
|
|
2747
|
+
letters: '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754',
|
|
2748
|
+
},
|
|
2749
|
+
{ base: 'Q', letters: '\u0051\u24C6\uFF31\uA756\uA758\u024A' },
|
|
2750
|
+
{
|
|
2751
|
+
base: 'R',
|
|
2752
|
+
letters: '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782',
|
|
2753
|
+
},
|
|
2754
|
+
{
|
|
2755
|
+
base: 'S',
|
|
2756
|
+
letters: '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784',
|
|
2757
|
+
},
|
|
2758
|
+
{
|
|
2759
|
+
base: 'T',
|
|
2760
|
+
letters: '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786',
|
|
2761
|
+
},
|
|
2762
|
+
{ base: 'TZ', letters: '\uA728' },
|
|
2763
|
+
{
|
|
2764
|
+
base: 'U',
|
|
2765
|
+
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',
|
|
2766
|
+
},
|
|
2767
|
+
{ base: 'V', letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' },
|
|
2768
|
+
{ base: 'VY', letters: '\uA760' },
|
|
2769
|
+
{
|
|
2770
|
+
base: 'W',
|
|
2771
|
+
letters: '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72',
|
|
2772
|
+
},
|
|
2773
|
+
{ base: 'X', letters: '\u0058\u24CD\uFF38\u1E8A\u1E8C' },
|
|
2774
|
+
{
|
|
2775
|
+
base: 'Y',
|
|
2776
|
+
letters: '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE',
|
|
2777
|
+
},
|
|
2778
|
+
{
|
|
2779
|
+
base: 'Z',
|
|
2780
|
+
letters: '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762',
|
|
2781
|
+
},
|
|
2782
|
+
{
|
|
2783
|
+
base: 'a',
|
|
2784
|
+
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',
|
|
2785
|
+
},
|
|
2786
|
+
{ base: 'aa', letters: '\uA733' },
|
|
2787
|
+
{ base: 'ae', letters: '\u00E6\u01FD\u01E3' },
|
|
2788
|
+
{ base: 'ao', letters: '\uA735' },
|
|
2789
|
+
{ base: 'au', letters: '\uA737' },
|
|
2790
|
+
{ base: 'av', letters: '\uA739\uA73B' },
|
|
2791
|
+
{ base: 'ay', letters: '\uA73D' },
|
|
2792
|
+
{
|
|
2793
|
+
base: 'b',
|
|
2794
|
+
letters: '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253',
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
base: 'c',
|
|
2798
|
+
letters: '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184',
|
|
2799
|
+
},
|
|
2800
|
+
{
|
|
2801
|
+
base: 'd',
|
|
2802
|
+
letters: '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A',
|
|
2803
|
+
},
|
|
2804
|
+
{ base: 'dz', letters: '\u01F3\u01C6' },
|
|
2805
|
+
{
|
|
2806
|
+
base: 'e',
|
|
2807
|
+
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',
|
|
2808
|
+
},
|
|
2809
|
+
{ base: 'f', letters: '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' },
|
|
2810
|
+
{
|
|
2811
|
+
base: 'g',
|
|
2812
|
+
letters: '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F',
|
|
2813
|
+
},
|
|
2814
|
+
{
|
|
2815
|
+
base: 'h',
|
|
2816
|
+
letters: '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265',
|
|
2817
|
+
},
|
|
2818
|
+
{ base: 'hv', letters: '\u0195' },
|
|
2819
|
+
{
|
|
2820
|
+
base: 'i',
|
|
2821
|
+
letters: '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131',
|
|
2822
|
+
},
|
|
2823
|
+
{ base: 'j', letters: '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' },
|
|
2824
|
+
{
|
|
2825
|
+
base: 'k',
|
|
2826
|
+
letters: '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3',
|
|
2827
|
+
},
|
|
2828
|
+
{
|
|
2829
|
+
base: 'l',
|
|
2830
|
+
letters: '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747',
|
|
2831
|
+
},
|
|
2832
|
+
{ base: 'lj', letters: '\u01C9' },
|
|
2833
|
+
{ base: 'm', letters: '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' },
|
|
2834
|
+
{
|
|
2835
|
+
base: 'n',
|
|
2836
|
+
letters: '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5',
|
|
2837
|
+
},
|
|
2838
|
+
{ base: 'nj', letters: '\u01CC' },
|
|
2839
|
+
{
|
|
2840
|
+
base: 'o',
|
|
2841
|
+
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',
|
|
2842
|
+
},
|
|
2843
|
+
{ base: 'oi', letters: '\u01A3' },
|
|
2844
|
+
{ base: 'ou', letters: '\u0223' },
|
|
2845
|
+
{ base: 'oo', letters: '\uA74F' },
|
|
2846
|
+
{
|
|
2847
|
+
base: 'p',
|
|
2848
|
+
letters: '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755',
|
|
2849
|
+
},
|
|
2850
|
+
{ base: 'q', letters: '\u0071\u24E0\uFF51\u024B\uA757\uA759' },
|
|
2851
|
+
{
|
|
2852
|
+
base: 'r',
|
|
2853
|
+
letters: '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783',
|
|
2854
|
+
},
|
|
2855
|
+
{
|
|
2856
|
+
base: 's',
|
|
2857
|
+
letters: '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B',
|
|
2858
|
+
},
|
|
2859
|
+
{
|
|
2860
|
+
base: 't',
|
|
2861
|
+
letters: '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787',
|
|
2862
|
+
},
|
|
2863
|
+
{ base: 'tz', letters: '\uA729' },
|
|
2864
|
+
{
|
|
2865
|
+
base: 'u',
|
|
2866
|
+
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',
|
|
2867
|
+
},
|
|
2868
|
+
{ base: 'v', letters: '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' },
|
|
2869
|
+
{ base: 'vy', letters: '\uA761' },
|
|
2870
|
+
{
|
|
2871
|
+
base: 'w',
|
|
2872
|
+
letters: '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73',
|
|
2873
|
+
},
|
|
2874
|
+
{ base: 'x', letters: '\u0078\u24E7\uFF58\u1E8B\u1E8D' },
|
|
2875
|
+
{
|
|
2876
|
+
base: 'y',
|
|
2877
|
+
letters: '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF',
|
|
2878
|
+
},
|
|
2879
|
+
{
|
|
2880
|
+
base: 'z',
|
|
2881
|
+
letters: '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763',
|
|
2882
|
+
},
|
|
2883
|
+
];
|
|
2884
|
+
/**
|
|
2885
|
+
* Map of letters from diacritic variant to diacritless variant
|
|
2886
|
+
* Contains lowercase and uppercase separatelly
|
|
2887
|
+
*
|
|
2888
|
+
* > "á" => "a"
|
|
2889
|
+
* > "ě" => "e"
|
|
2890
|
+
* > "Ă" => "A"
|
|
2891
|
+
* > ...
|
|
2892
|
+
*
|
|
2893
|
+
* @public exported from `@promptbook/utils`
|
|
2894
|
+
*/
|
|
2895
|
+
var DIACRITIC_VARIANTS_LETTERS = {};
|
|
2896
|
+
// tslint:disable-next-line: prefer-for-of
|
|
2897
|
+
for (var i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
2898
|
+
var letters = defaultDiacriticsRemovalMap[i].letters;
|
|
2899
|
+
// tslint:disable-next-line: prefer-for-of
|
|
2900
|
+
for (var j = 0; j < letters.length; j++) {
|
|
2901
|
+
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
// <- TODO: [🍓] Put to maker function to save execution time if not needed
|
|
2905
|
+
/*
|
|
2906
|
+
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
2907
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
2908
|
+
you may not use this file except in compliance with the License.
|
|
2909
|
+
You may obtain a copy of the License at
|
|
2910
|
+
|
|
2911
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
2912
|
+
|
|
2913
|
+
Unless required by applicable law or agreed to in writing, software
|
|
2914
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
2915
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2916
|
+
See the License for the specific language governing permissions and
|
|
2917
|
+
limitations under the License.
|
|
2918
|
+
*/
|
|
2903
2919
|
|
|
2904
2920
|
/**
|
|
2905
2921
|
* @@@
|
|
2906
2922
|
*
|
|
2907
|
-
*
|
|
2908
|
-
* @
|
|
2909
|
-
* @public exported from `@promptbook/
|
|
2923
|
+
* @param input @@@
|
|
2924
|
+
* @returns @@@
|
|
2925
|
+
* @public exported from `@promptbook/utils`
|
|
2910
2926
|
*/
|
|
2911
|
-
|
|
2927
|
+
function removeDiacritics(input) {
|
|
2928
|
+
/*eslint no-control-regex: "off"*/
|
|
2929
|
+
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
2930
|
+
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
2931
|
+
});
|
|
2932
|
+
}
|
|
2912
2933
|
/**
|
|
2913
|
-
* TODO: [
|
|
2934
|
+
* TODO: [Ж] Variant for cyrillic (and in general non-latin) letters
|
|
2914
2935
|
*/
|
|
2915
2936
|
|
|
2916
2937
|
/**
|
|
2917
|
-
*
|
|
2918
|
-
*
|
|
2919
|
-
* Note: This function is used to create a (error) message when there is no scraper for particular mime type
|
|
2938
|
+
* @@@
|
|
2920
2939
|
*
|
|
2921
|
-
* @
|
|
2940
|
+
* @param text @@@
|
|
2941
|
+
* @returns @@@
|
|
2942
|
+
* @example 'hello-world'
|
|
2943
|
+
* @example 'i-love-promptbook'
|
|
2944
|
+
* @public exported from `@promptbook/utils`
|
|
2922
2945
|
*/
|
|
2923
|
-
function
|
|
2924
|
-
var e_1, _a
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
var
|
|
2929
|
-
var _loop_1 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
|
|
2930
|
-
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
2931
|
-
return "continue";
|
|
2932
|
-
}
|
|
2933
|
-
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
2934
|
-
};
|
|
2946
|
+
function normalizeToKebabCase(text) {
|
|
2947
|
+
var e_1, _a;
|
|
2948
|
+
text = removeDiacritics(text);
|
|
2949
|
+
var charType;
|
|
2950
|
+
var lastCharType = 'OTHER';
|
|
2951
|
+
var normalizedName = '';
|
|
2935
2952
|
try {
|
|
2936
|
-
for (var
|
|
2937
|
-
var
|
|
2938
|
-
|
|
2953
|
+
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
2954
|
+
var char = text_1_1.value;
|
|
2955
|
+
var normalizedChar = void 0;
|
|
2956
|
+
if (/^[a-z]$/.test(char)) {
|
|
2957
|
+
charType = 'LOWERCASE';
|
|
2958
|
+
normalizedChar = char;
|
|
2959
|
+
}
|
|
2960
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
2961
|
+
charType = 'UPPERCASE';
|
|
2962
|
+
normalizedChar = char.toLowerCase();
|
|
2963
|
+
}
|
|
2964
|
+
else if (/^[0-9]$/.test(char)) {
|
|
2965
|
+
charType = 'NUMBER';
|
|
2966
|
+
normalizedChar = char;
|
|
2967
|
+
}
|
|
2968
|
+
else {
|
|
2969
|
+
charType = 'OTHER';
|
|
2970
|
+
normalizedChar = '-';
|
|
2971
|
+
}
|
|
2972
|
+
if (charType !== lastCharType &&
|
|
2973
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
2974
|
+
!(lastCharType === 'NUMBER') &&
|
|
2975
|
+
!(charType === 'NUMBER')) {
|
|
2976
|
+
normalizedName += '-';
|
|
2977
|
+
}
|
|
2978
|
+
normalizedName += normalizedChar;
|
|
2979
|
+
lastCharType = charType;
|
|
2939
2980
|
}
|
|
2940
2981
|
}
|
|
2941
2982
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2942
2983
|
finally {
|
|
2943
2984
|
try {
|
|
2944
|
-
if (
|
|
2985
|
+
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
2945
2986
|
}
|
|
2946
2987
|
finally { if (e_1) throw e_1.error; }
|
|
2947
2988
|
}
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
};
|
|
2954
|
-
try {
|
|
2955
|
-
for (var _g = __values($scrapersRegister.list()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2956
|
-
var _j = _h.value, packageName = _j.packageName, className = _j.className, mimeTypes = _j.mimeTypes, documentationUrl = _j.documentationUrl, isAvilableInBrowser = _j.isAvilableInBrowser;
|
|
2957
|
-
_loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
2958
|
-
}
|
|
2959
|
-
}
|
|
2960
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2961
|
-
finally {
|
|
2962
|
-
try {
|
|
2963
|
-
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
2964
|
-
}
|
|
2965
|
-
finally { if (e_2) throw e_2.error; }
|
|
2966
|
-
}
|
|
2967
|
-
try {
|
|
2968
|
-
for (var availableScrapers_1 = __values(availableScrapers), availableScrapers_1_1 = availableScrapers_1.next(); !availableScrapers_1_1.done; availableScrapers_1_1 = availableScrapers_1.next()) {
|
|
2969
|
-
var metadata_1 = availableScrapers_1_1.value.metadata;
|
|
2970
|
-
all.push(metadata_1);
|
|
2971
|
-
}
|
|
2972
|
-
}
|
|
2973
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
2974
|
-
finally {
|
|
2975
|
-
try {
|
|
2976
|
-
if (availableScrapers_1_1 && !availableScrapers_1_1.done && (_c = availableScrapers_1.return)) _c.call(availableScrapers_1);
|
|
2977
|
-
}
|
|
2978
|
-
finally { if (e_3) throw e_3.error; }
|
|
2979
|
-
}
|
|
2980
|
-
var metadata = all.map(function (metadata) {
|
|
2981
|
-
var isMetadataAviailable = $scrapersMetadataRegister
|
|
2982
|
-
.list()
|
|
2983
|
-
.find(function (_a) {
|
|
2984
|
-
var packageName = _a.packageName, className = _a.className;
|
|
2985
|
-
return metadata.packageName === packageName && metadata.className === className;
|
|
2986
|
-
});
|
|
2987
|
-
var isInstalled = $scrapersRegister
|
|
2988
|
-
.list()
|
|
2989
|
-
.find(function (_a) {
|
|
2990
|
-
var packageName = _a.packageName, className = _a.className;
|
|
2991
|
-
return metadata.packageName === packageName && metadata.className === className;
|
|
2992
|
-
});
|
|
2993
|
-
var isAvilableInTools = availableScrapers.some(function (_a) {
|
|
2994
|
-
var _b = _a.metadata, packageName = _b.packageName, className = _b.className;
|
|
2995
|
-
return metadata.packageName === packageName && metadata.className === className;
|
|
2996
|
-
});
|
|
2997
|
-
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
|
|
2998
|
-
});
|
|
2999
|
-
if (metadata.length === 0) {
|
|
3000
|
-
return spaceTrim$1("\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 ");
|
|
3001
|
-
}
|
|
3002
|
-
return spaceTrim$1(function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
|
|
3003
|
-
.map(function (_a, i) {
|
|
3004
|
-
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
|
|
3005
|
-
var more = [];
|
|
3006
|
-
// TODO: [🧠] Maybe use `documentationUrl`
|
|
3007
|
-
if (isMetadataAviailable) {
|
|
3008
|
-
more.push("\u2B1C Metadata registered");
|
|
3009
|
-
} // not else
|
|
3010
|
-
if (isInstalled) {
|
|
3011
|
-
more.push("\uD83D\uDFE9 Installed");
|
|
3012
|
-
} // not else
|
|
3013
|
-
if (isAvilableInTools) {
|
|
3014
|
-
more.push("\uD83D\uDFE6 Available in tools");
|
|
3015
|
-
} // not else
|
|
3016
|
-
if (!isMetadataAviailable && isInstalled) {
|
|
3017
|
-
more.push("When no metadata registered but scraper is installed, it is an unexpected behavior");
|
|
3018
|
-
} // not else
|
|
3019
|
-
if (!isInstalled && isAvilableInTools) {
|
|
3020
|
-
more.push("When the scraper is not installed but available in tools, it is an unexpected compatibility behavior");
|
|
3021
|
-
} // not else
|
|
3022
|
-
if (!isAvilableInBrowser) {
|
|
3023
|
-
more.push("Not usable in browser");
|
|
3024
|
-
}
|
|
3025
|
-
var moreText = more.length === 0 ? '' : " *(".concat(more.join('; '), ")*");
|
|
3026
|
-
return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes
|
|
3027
|
-
.map(function (mimeType) { return "\"".concat(mimeType, "\""); })
|
|
3028
|
-
.join(', ')).concat(moreText);
|
|
3029
|
-
})
|
|
3030
|
-
.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 "); });
|
|
2989
|
+
normalizedName = normalizedName.split(/-+/g).join('-');
|
|
2990
|
+
normalizedName = normalizedName.split(/-?\/-?/g).join('/');
|
|
2991
|
+
normalizedName = normalizedName.replace(/^-/, '');
|
|
2992
|
+
normalizedName = normalizedName.replace(/-$/, '');
|
|
2993
|
+
return normalizedName;
|
|
3031
2994
|
}
|
|
3032
2995
|
/**
|
|
3033
|
-
*
|
|
2996
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3034
2997
|
*/
|
|
3035
2998
|
|
|
3036
2999
|
/**
|
|
@@ -3109,6 +3072,32 @@ function isFileExisting(filename, fs) {
|
|
|
3109
3072
|
* TODO: [🖇] What about symlinks?
|
|
3110
3073
|
*/
|
|
3111
3074
|
|
|
3075
|
+
/**
|
|
3076
|
+
* Tests if given string is valid URL.
|
|
3077
|
+
*
|
|
3078
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
3079
|
+
* @public exported from `@promptbook/utils`
|
|
3080
|
+
*/
|
|
3081
|
+
function isValidFilePath(filename) {
|
|
3082
|
+
if (typeof filename !== 'string') {
|
|
3083
|
+
return false;
|
|
3084
|
+
}
|
|
3085
|
+
var filenameSlashes = filename.split('\\').join('/');
|
|
3086
|
+
// Absolute Unix path: /hello.txt
|
|
3087
|
+
if (/^(\/)/i.test(filenameSlashes)) {
|
|
3088
|
+
return true;
|
|
3089
|
+
}
|
|
3090
|
+
// Absolute Windows path: /hello.txt
|
|
3091
|
+
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
3092
|
+
return true;
|
|
3093
|
+
}
|
|
3094
|
+
// Relative path: ./hello.txt
|
|
3095
|
+
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
3096
|
+
return true;
|
|
3097
|
+
}
|
|
3098
|
+
return false;
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3112
3101
|
/**
|
|
3113
3102
|
* @@@
|
|
3114
3103
|
*
|
|
@@ -3570,9 +3559,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3570
3559
|
* @param script from which to extract the variables
|
|
3571
3560
|
* @returns the list of variable names
|
|
3572
3561
|
* @throws {ParseError} if the script is invalid
|
|
3573
|
-
* @public exported from `@promptbook/utils`
|
|
3562
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
3574
3563
|
*/
|
|
3575
|
-
function
|
|
3564
|
+
function extractVariablesFromScript(script) {
|
|
3576
3565
|
var variables = new Set();
|
|
3577
3566
|
script = "(()=>{".concat(script, "})()");
|
|
3578
3567
|
try {
|
|
@@ -3619,7 +3608,7 @@ function extractVariables(script) {
|
|
|
3619
3608
|
* @param task the task with used parameters
|
|
3620
3609
|
* @returns the set of parameter names
|
|
3621
3610
|
* @throws {ParseError} if the script is invalid
|
|
3622
|
-
* @public exported from `@promptbook/
|
|
3611
|
+
* @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
|
|
3623
3612
|
*/
|
|
3624
3613
|
function extractParameterNamesFromTask(task) {
|
|
3625
3614
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
@@ -3640,7 +3629,7 @@ function extractParameterNamesFromTask(task) {
|
|
|
3640
3629
|
}
|
|
3641
3630
|
if (taskType === 'SCRIPT_TASK') {
|
|
3642
3631
|
try {
|
|
3643
|
-
for (var _g = __values(
|
|
3632
|
+
for (var _g = __values(extractVariablesFromScript(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
3644
3633
|
var parameterName = _h.value;
|
|
3645
3634
|
parameterNames.add(parameterName);
|
|
3646
3635
|
}
|
|
@@ -5549,6 +5538,46 @@ function createPipelineExecutor(options) {
|
|
|
5549
5538
|
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
5550
5539
|
*/
|
|
5551
5540
|
|
|
5541
|
+
/**
|
|
5542
|
+
* Removes emojis from a string and fix whitespaces
|
|
5543
|
+
*
|
|
5544
|
+
* @param text with emojis
|
|
5545
|
+
* @returns text without emojis
|
|
5546
|
+
* @public exported from `@promptbook/utils`
|
|
5547
|
+
*/
|
|
5548
|
+
function removeEmojis(text) {
|
|
5549
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
5550
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
5551
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
5552
|
+
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
5553
|
+
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
5554
|
+
return text;
|
|
5555
|
+
}
|
|
5556
|
+
|
|
5557
|
+
/**
|
|
5558
|
+
* @@@
|
|
5559
|
+
*
|
|
5560
|
+
* @param value @@@
|
|
5561
|
+
* @returns @@@
|
|
5562
|
+
* @example @@@
|
|
5563
|
+
* @public exported from `@promptbook/utils`
|
|
5564
|
+
*/
|
|
5565
|
+
function titleToName(value) {
|
|
5566
|
+
if (isValidUrl(value)) {
|
|
5567
|
+
value = value.replace(/^https?:\/\//, '');
|
|
5568
|
+
value = value.replace(/\.html$/, '');
|
|
5569
|
+
}
|
|
5570
|
+
else if (isValidFilePath(value)) {
|
|
5571
|
+
value = basename(value);
|
|
5572
|
+
// Note: Keeping extension in the name
|
|
5573
|
+
}
|
|
5574
|
+
value = value.split('/').join('-');
|
|
5575
|
+
value = removeEmojis(value);
|
|
5576
|
+
value = normalizeToKebabCase(value);
|
|
5577
|
+
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
5578
|
+
return value;
|
|
5579
|
+
}
|
|
5580
|
+
|
|
5552
5581
|
/**
|
|
5553
5582
|
* Metadata of the scraper
|
|
5554
5583
|
*
|