@promptbook/pdf 0.77.1 → 0.78.2
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/esm/index.es.js +837 -795
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +10 -0
- 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/commands/_common/types/CommandType.d.ts +17 -0
- package/esm/typings/src/config.d.ts +14 -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/utils/getErrorReportUrl.d.ts +6 -0
- package/esm/typings/src/execution/execution-report/ExecutionReportString.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineString.d.ts +1 -1
- package/esm/typings/src/utils/normalization/titleToName.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +840 -798
- 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.
|
|
23
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.78.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
|
|
@@ -446,198 +446,25 @@ function just(value) {
|
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
/**
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
452
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
449
|
+
* Name for the Promptbook
|
|
453
450
|
*
|
|
454
|
-
*
|
|
455
|
-
* @public exported from `@promptbook/utils`
|
|
456
|
-
*/
|
|
457
|
-
function $deepFreeze(objectValue) {
|
|
458
|
-
var e_1, _a;
|
|
459
|
-
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
460
|
-
try {
|
|
461
|
-
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
462
|
-
var propertyName = propertyNames_1_1.value;
|
|
463
|
-
var value = objectValue[propertyName];
|
|
464
|
-
if (value && typeof value === 'object') {
|
|
465
|
-
$deepFreeze(value);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
470
|
-
finally {
|
|
471
|
-
try {
|
|
472
|
-
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
473
|
-
}
|
|
474
|
-
finally { if (e_1) throw e_1.error; }
|
|
475
|
-
}
|
|
476
|
-
return Object.freeze(objectValue);
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
480
|
-
*/
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
451
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
484
452
|
*
|
|
485
453
|
* @public exported from `@promptbook/core`
|
|
486
454
|
*/
|
|
487
|
-
var
|
|
488
|
-
__extends(UnexpectedError, _super);
|
|
489
|
-
function UnexpectedError(message) {
|
|
490
|
-
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
491
|
-
_this.name = 'UnexpectedError';
|
|
492
|
-
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
493
|
-
return _this;
|
|
494
|
-
}
|
|
495
|
-
return UnexpectedError;
|
|
496
|
-
}(Error));
|
|
497
|
-
|
|
455
|
+
var NAME = "Promptbook";
|
|
498
456
|
/**
|
|
499
|
-
*
|
|
500
|
-
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
501
|
-
*
|
|
502
|
-
* - Almost all primitives are serializable BUT:
|
|
503
|
-
* - `undefined` is not serializable
|
|
504
|
-
* - `NaN` is not serializable
|
|
505
|
-
* - Objects and arrays are serializable if all their properties are serializable
|
|
506
|
-
* - Functions are not serializable
|
|
507
|
-
* - Circular references are not serializable
|
|
508
|
-
* - `Date` objects are not serializable
|
|
509
|
-
* - `Map` and `Set` objects are not serializable
|
|
510
|
-
* - `RegExp` objects are not serializable
|
|
511
|
-
* - `Error` objects are not serializable
|
|
512
|
-
* - `Symbol` objects are not serializable
|
|
513
|
-
* - And much more...
|
|
457
|
+
* Email of the responsible person
|
|
514
458
|
*
|
|
515
|
-
* @
|
|
516
|
-
* @public exported from `@promptbook/utils`
|
|
517
|
-
*/
|
|
518
|
-
function checkSerializableAsJson(name, value) {
|
|
519
|
-
var e_1, _a;
|
|
520
|
-
if (value === undefined) {
|
|
521
|
-
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
522
|
-
}
|
|
523
|
-
else if (value === null) {
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
else if (typeof value === 'boolean') {
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
else if (typeof value === 'number' && !isNaN(value)) {
|
|
530
|
-
return;
|
|
531
|
-
}
|
|
532
|
-
else if (typeof value === 'string') {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
else if (typeof value === 'symbol') {
|
|
536
|
-
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
537
|
-
}
|
|
538
|
-
else if (typeof value === 'function') {
|
|
539
|
-
throw new UnexpectedError("".concat(name, " is function"));
|
|
540
|
-
}
|
|
541
|
-
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
542
|
-
for (var i = 0; i < value.length; i++) {
|
|
543
|
-
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
else if (typeof value === 'object') {
|
|
547
|
-
if (value instanceof Date) {
|
|
548
|
-
throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
549
|
-
}
|
|
550
|
-
else if (value instanceof Map) {
|
|
551
|
-
throw new UnexpectedError("".concat(name, " is Map"));
|
|
552
|
-
}
|
|
553
|
-
else if (value instanceof Set) {
|
|
554
|
-
throw new UnexpectedError("".concat(name, " is Set"));
|
|
555
|
-
}
|
|
556
|
-
else if (value instanceof RegExp) {
|
|
557
|
-
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
558
|
-
}
|
|
559
|
-
else if (value instanceof Error) {
|
|
560
|
-
throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
try {
|
|
564
|
-
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
565
|
-
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
566
|
-
if (subValue === undefined) {
|
|
567
|
-
// Note: undefined in object is serializable - it is just omited
|
|
568
|
-
continue;
|
|
569
|
-
}
|
|
570
|
-
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
574
|
-
finally {
|
|
575
|
-
try {
|
|
576
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
577
|
-
}
|
|
578
|
-
finally { if (e_1) throw e_1.error; }
|
|
579
|
-
}
|
|
580
|
-
try {
|
|
581
|
-
JSON.stringify(value); // <- TODO: [0]
|
|
582
|
-
}
|
|
583
|
-
catch (error) {
|
|
584
|
-
if (!(error instanceof Error)) {
|
|
585
|
-
throw error;
|
|
586
|
-
}
|
|
587
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
588
|
-
}
|
|
589
|
-
/*
|
|
590
|
-
TODO: [0] Is there some more elegant way to check circular references?
|
|
591
|
-
const seen = new Set();
|
|
592
|
-
const stack = [{ value }];
|
|
593
|
-
while (stack.length > 0) {
|
|
594
|
-
const { value } = stack.pop()!;
|
|
595
|
-
if (typeof value === 'object' && value !== null) {
|
|
596
|
-
if (seen.has(value)) {
|
|
597
|
-
throw new UnexpectedError(`${name} has circular reference`);
|
|
598
|
-
}
|
|
599
|
-
seen.add(value);
|
|
600
|
-
if (Array.isArray(value)) {
|
|
601
|
-
stack.push(...value.map((value) => ({ value })));
|
|
602
|
-
} else {
|
|
603
|
-
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
*/
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
else {
|
|
612
|
-
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
617
|
-
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
618
|
-
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
459
|
+
* @public exported from `@promptbook/core`
|
|
619
460
|
*/
|
|
620
|
-
|
|
461
|
+
var ADMIN_EMAIL = 'me@pavolhejny.com';
|
|
621
462
|
/**
|
|
622
|
-
*
|
|
623
|
-
* @@@
|
|
624
|
-
*
|
|
625
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
463
|
+
* Name of the responsible person for the Promptbook on GitHub
|
|
626
464
|
*
|
|
627
|
-
* @
|
|
628
|
-
* @param objectValue - Object to be deeply frozen
|
|
629
|
-
* @returns The same object as the input, but deeply frozen
|
|
630
|
-
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
631
|
-
*/
|
|
632
|
-
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
633
|
-
checkSerializableAsJson(name, objectValue);
|
|
634
|
-
return $deepFreeze(objectValue);
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
638
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
465
|
+
* @public exported from `@promptbook/core`
|
|
639
466
|
*/
|
|
640
|
-
|
|
467
|
+
var ADMIN_GITHUB_NAME = 'hejny';
|
|
641
468
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
642
469
|
/**
|
|
643
470
|
* The maximum number of iterations for a loops
|
|
@@ -689,7 +516,8 @@ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
|
689
516
|
*
|
|
690
517
|
* @public exported from `@promptbook/core`
|
|
691
518
|
*/
|
|
692
|
-
var RESERVED_PARAMETER_NAMES =
|
|
519
|
+
var RESERVED_PARAMETER_NAMES =
|
|
520
|
+
/* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
|
|
693
521
|
'content',
|
|
694
522
|
'context',
|
|
695
523
|
'knowledge',
|
|
@@ -699,7 +527,7 @@ var RESERVED_PARAMETER_NAMES = $asDeeplyFrozenSerializableJson('RESERVED_PARAMET
|
|
|
699
527
|
// <- TODO: list here all command names
|
|
700
528
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
701
529
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
702
|
-
]
|
|
530
|
+
];
|
|
703
531
|
/**
|
|
704
532
|
* @@@
|
|
705
533
|
*
|
|
@@ -786,6 +614,40 @@ var PipelineLogicError = /** @class */ (function (_super) {
|
|
|
786
614
|
return PipelineLogicError;
|
|
787
615
|
}(Error));
|
|
788
616
|
|
|
617
|
+
/**
|
|
618
|
+
* Make error report URL for the given error
|
|
619
|
+
*
|
|
620
|
+
* @private !!!!!!
|
|
621
|
+
*/
|
|
622
|
+
function getErrorReportUrl(error) {
|
|
623
|
+
var report = {
|
|
624
|
+
title: "\uD83D\uDC1C Error report from ".concat(NAME),
|
|
625
|
+
body: spaceTrim$1(function (block) { return "\n\n\n `".concat(error.name || 'Error', "` has occurred in the [").concat(NAME, "], please look into it @").concat(ADMIN_GITHUB_NAME, ".\n\n ```\n ").concat(block(error.message || '(no error message)'), "\n ```\n\n\n ## More info:\n\n - **Promptbook engine version:** ").concat(PROMPTBOOK_ENGINE_VERSION, "\n - **Book language version:** ").concat(BOOK_LANGUAGE_VERSION, "\n - **Time:** ").concat(new Date().toISOString(), "\n\n <details>\n <summary>Stack trace:</summary>\n\n ## Stack trace:\n\n ```stacktrace\n ").concat(block(error.stack || '(empty)'), "\n ```\n </details>\n\n "); }),
|
|
626
|
+
};
|
|
627
|
+
var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
|
|
628
|
+
reportUrl.searchParams.set('labels', 'bug');
|
|
629
|
+
reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
|
|
630
|
+
reportUrl.searchParams.set('title', report.title);
|
|
631
|
+
reportUrl.searchParams.set('body', report.body);
|
|
632
|
+
return reportUrl;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
637
|
+
*
|
|
638
|
+
* @public exported from `@promptbook/core`
|
|
639
|
+
*/
|
|
640
|
+
var UnexpectedError = /** @class */ (function (_super) {
|
|
641
|
+
__extends(UnexpectedError, _super);
|
|
642
|
+
function UnexpectedError(message) {
|
|
643
|
+
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n ").concat(block(getErrorReportUrl(new Error(message)).href), "\n\n Or contact us on ").concat(ADMIN_EMAIL, "\n\n "); })) || this;
|
|
644
|
+
_this.name = 'UnexpectedError';
|
|
645
|
+
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
646
|
+
return _this;
|
|
647
|
+
}
|
|
648
|
+
return UnexpectedError;
|
|
649
|
+
}(Error));
|
|
650
|
+
|
|
789
651
|
/**
|
|
790
652
|
* Tests if given string is valid semantic version
|
|
791
653
|
*
|
|
@@ -1267,36 +1129,213 @@ function extractParameterNames(template) {
|
|
|
1267
1129
|
}
|
|
1268
1130
|
|
|
1269
1131
|
/**
|
|
1270
|
-
*
|
|
1132
|
+
* @@@
|
|
1271
1133
|
*
|
|
1272
|
-
*
|
|
1134
|
+
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
1135
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1136
|
+
*
|
|
1137
|
+
* @returns The same object as the input, but deeply frozen
|
|
1138
|
+
* @public exported from `@promptbook/utils`
|
|
1273
1139
|
*/
|
|
1274
|
-
function
|
|
1275
|
-
var
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1140
|
+
function $deepFreeze(objectValue) {
|
|
1141
|
+
var e_1, _a;
|
|
1142
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1143
|
+
try {
|
|
1144
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
1145
|
+
var propertyName = propertyNames_1_1.value;
|
|
1146
|
+
var value = objectValue[propertyName];
|
|
1147
|
+
if (value && typeof value === 'object') {
|
|
1148
|
+
$deepFreeze(value);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1153
|
+
finally {
|
|
1154
|
+
try {
|
|
1155
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
1156
|
+
}
|
|
1157
|
+
finally { if (e_1) throw e_1.error; }
|
|
1158
|
+
}
|
|
1159
|
+
return Object.freeze(objectValue);
|
|
1287
1160
|
}
|
|
1288
1161
|
/**
|
|
1289
|
-
* TODO: [
|
|
1290
|
-
* TODO: Write tests for `preparePipeline`
|
|
1291
|
-
* TODO: [🍙] Make some standard order of json properties
|
|
1162
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1292
1163
|
*/
|
|
1293
1164
|
|
|
1294
1165
|
/**
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1166
|
+
* Checks if the value is [🚉] serializable as JSON
|
|
1167
|
+
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
1297
1168
|
*
|
|
1298
|
-
*
|
|
1299
|
-
*
|
|
1169
|
+
* - Almost all primitives are serializable BUT:
|
|
1170
|
+
* - `undefined` is not serializable
|
|
1171
|
+
* - `NaN` is not serializable
|
|
1172
|
+
* - Objects and arrays are serializable if all their properties are serializable
|
|
1173
|
+
* - Functions are not serializable
|
|
1174
|
+
* - Circular references are not serializable
|
|
1175
|
+
* - `Date` objects are not serializable
|
|
1176
|
+
* - `Map` and `Set` objects are not serializable
|
|
1177
|
+
* - `RegExp` objects are not serializable
|
|
1178
|
+
* - `Error` objects are not serializable
|
|
1179
|
+
* - `Symbol` objects are not serializable
|
|
1180
|
+
* - And much more...
|
|
1181
|
+
*
|
|
1182
|
+
* @throws UnexpectedError if the value is not serializable as JSON
|
|
1183
|
+
* @public exported from `@promptbook/utils`
|
|
1184
|
+
*/
|
|
1185
|
+
function checkSerializableAsJson(name, value) {
|
|
1186
|
+
var e_1, _a;
|
|
1187
|
+
if (value === undefined) {
|
|
1188
|
+
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
1189
|
+
}
|
|
1190
|
+
else if (value === null) {
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
else if (typeof value === 'boolean') {
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
else if (typeof value === 'number' && !isNaN(value)) {
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
else if (typeof value === 'string') {
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
else if (typeof value === 'symbol') {
|
|
1203
|
+
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
1204
|
+
}
|
|
1205
|
+
else if (typeof value === 'function') {
|
|
1206
|
+
throw new UnexpectedError("".concat(name, " is function"));
|
|
1207
|
+
}
|
|
1208
|
+
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
1209
|
+
for (var i = 0; i < value.length; i++) {
|
|
1210
|
+
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
else if (typeof value === 'object') {
|
|
1214
|
+
if (value instanceof Date) {
|
|
1215
|
+
throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
1216
|
+
}
|
|
1217
|
+
else if (value instanceof Map) {
|
|
1218
|
+
throw new UnexpectedError("".concat(name, " is Map"));
|
|
1219
|
+
}
|
|
1220
|
+
else if (value instanceof Set) {
|
|
1221
|
+
throw new UnexpectedError("".concat(name, " is Set"));
|
|
1222
|
+
}
|
|
1223
|
+
else if (value instanceof RegExp) {
|
|
1224
|
+
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
1225
|
+
}
|
|
1226
|
+
else if (value instanceof Error) {
|
|
1227
|
+
throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
1228
|
+
}
|
|
1229
|
+
else {
|
|
1230
|
+
try {
|
|
1231
|
+
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1232
|
+
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
1233
|
+
if (subValue === undefined) {
|
|
1234
|
+
// Note: undefined in object is serializable - it is just omited
|
|
1235
|
+
continue;
|
|
1236
|
+
}
|
|
1237
|
+
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1241
|
+
finally {
|
|
1242
|
+
try {
|
|
1243
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1244
|
+
}
|
|
1245
|
+
finally { if (e_1) throw e_1.error; }
|
|
1246
|
+
}
|
|
1247
|
+
try {
|
|
1248
|
+
JSON.stringify(value); // <- TODO: [0]
|
|
1249
|
+
}
|
|
1250
|
+
catch (error) {
|
|
1251
|
+
if (!(error instanceof Error)) {
|
|
1252
|
+
throw error;
|
|
1253
|
+
}
|
|
1254
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
1255
|
+
}
|
|
1256
|
+
/*
|
|
1257
|
+
TODO: [0] Is there some more elegant way to check circular references?
|
|
1258
|
+
const seen = new Set();
|
|
1259
|
+
const stack = [{ value }];
|
|
1260
|
+
while (stack.length > 0) {
|
|
1261
|
+
const { value } = stack.pop()!;
|
|
1262
|
+
if (typeof value === 'object' && value !== null) {
|
|
1263
|
+
if (seen.has(value)) {
|
|
1264
|
+
throw new UnexpectedError(`${name} has circular reference`);
|
|
1265
|
+
}
|
|
1266
|
+
seen.add(value);
|
|
1267
|
+
if (Array.isArray(value)) {
|
|
1268
|
+
stack.push(...value.map((value) => ({ value })));
|
|
1269
|
+
} else {
|
|
1270
|
+
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
*/
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
1284
|
+
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
1285
|
+
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
1286
|
+
*/
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* @@@
|
|
1290
|
+
* @@@
|
|
1291
|
+
*
|
|
1292
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1293
|
+
*
|
|
1294
|
+
* @param name - Name of the object for debugging purposes
|
|
1295
|
+
* @param objectValue - Object to be deeply frozen
|
|
1296
|
+
* @returns The same object as the input, but deeply frozen
|
|
1297
|
+
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
1298
|
+
*/
|
|
1299
|
+
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
1300
|
+
checkSerializableAsJson(name, objectValue);
|
|
1301
|
+
return $deepFreeze(objectValue);
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
1305
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1306
|
+
*/
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Unprepare just strips the preparation data of the pipeline
|
|
1310
|
+
*
|
|
1311
|
+
* @public exported from `@promptbook/core`
|
|
1312
|
+
*/
|
|
1313
|
+
function unpreparePipeline(pipeline) {
|
|
1314
|
+
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
|
|
1315
|
+
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
1316
|
+
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1317
|
+
tasks = tasks.map(function (task) {
|
|
1318
|
+
var dependentParameterNames = task.dependentParameterNames;
|
|
1319
|
+
var parameterNames = extractParameterNames(task.preparedContent || '');
|
|
1320
|
+
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
1321
|
+
var taskUnprepared = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames });
|
|
1322
|
+
delete taskUnprepared.preparedContent;
|
|
1323
|
+
return taskUnprepared;
|
|
1324
|
+
});
|
|
1325
|
+
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
1329
|
+
* TODO: Write tests for `preparePipeline`
|
|
1330
|
+
* TODO: [🍙] Make some standard order of json properties
|
|
1331
|
+
*/
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* Library of pipelines that groups together pipelines for an application.
|
|
1335
|
+
* This implementation is a very thin wrapper around the Array / Map of pipelines.
|
|
1336
|
+
*
|
|
1337
|
+
* @private internal function of `createCollectionFromJson`, use `createCollectionFromJson` instead
|
|
1338
|
+
* @see https://github.com/webgptorg/pipeline#pipeline-collection
|
|
1300
1339
|
*/
|
|
1301
1340
|
var SimplePipelineCollection = /** @class */ (function () {
|
|
1302
1341
|
/**
|
|
@@ -1396,483 +1435,94 @@ function createCollectionFromJson() {
|
|
|
1396
1435
|
return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
1397
1436
|
}
|
|
1398
1437
|
|
|
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
1438
|
/**
|
|
1608
|
-
*
|
|
1609
|
-
* Contains lowercase and uppercase separatelly
|
|
1610
|
-
*
|
|
1611
|
-
* > "á" => "a"
|
|
1612
|
-
* > "ě" => "e"
|
|
1613
|
-
* > "Ă" => "A"
|
|
1614
|
-
* > ...
|
|
1439
|
+
* This error type indicates that some tools are missing for pipeline execution or preparation
|
|
1615
1440
|
*
|
|
1616
|
-
* @public exported from `@promptbook/
|
|
1441
|
+
* @public exported from `@promptbook/core`
|
|
1617
1442
|
*/
|
|
1618
|
-
var
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1443
|
+
var MissingToolsError = /** @class */ (function (_super) {
|
|
1444
|
+
__extends(MissingToolsError, _super);
|
|
1445
|
+
function MissingToolsError(message) {
|
|
1446
|
+
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;
|
|
1447
|
+
_this.name = 'MissingToolsError';
|
|
1448
|
+
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
1449
|
+
return _this;
|
|
1625
1450
|
}
|
|
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
|
|
1451
|
+
return MissingToolsError;
|
|
1452
|
+
}(Error));
|
|
1633
1453
|
|
|
1634
|
-
|
|
1454
|
+
/**
|
|
1455
|
+
* This error indicates errors during the execution of the pipeline
|
|
1456
|
+
*
|
|
1457
|
+
* @public exported from `@promptbook/core`
|
|
1458
|
+
*/
|
|
1459
|
+
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
1460
|
+
__extends(PipelineExecutionError, _super);
|
|
1461
|
+
function PipelineExecutionError(message) {
|
|
1462
|
+
var _this = _super.call(this, message) || this;
|
|
1463
|
+
_this.name = 'PipelineExecutionError';
|
|
1464
|
+
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
1465
|
+
return _this;
|
|
1466
|
+
}
|
|
1467
|
+
return PipelineExecutionError;
|
|
1468
|
+
}(Error));
|
|
1635
1469
|
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1470
|
+
/**
|
|
1471
|
+
* This error indicates problems parsing the format value
|
|
1472
|
+
*
|
|
1473
|
+
* For example, when the format value is not a valid JSON or CSV
|
|
1474
|
+
* This is not thrown directly but in extended classes
|
|
1475
|
+
*
|
|
1476
|
+
* @public exported from `@promptbook/core`
|
|
1477
|
+
*/
|
|
1478
|
+
var AbstractFormatError = /** @class */ (function (_super) {
|
|
1479
|
+
__extends(AbstractFormatError, _super);
|
|
1480
|
+
// Note: To allow instanceof do not put here error `name`
|
|
1481
|
+
// public readonly name = 'AbstractFormatError';
|
|
1482
|
+
function AbstractFormatError(message) {
|
|
1483
|
+
var _this = _super.call(this, message) || this;
|
|
1484
|
+
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
1485
|
+
return _this;
|
|
1486
|
+
}
|
|
1487
|
+
return AbstractFormatError;
|
|
1488
|
+
}(Error));
|
|
1642
1489
|
|
|
1643
1490
|
/**
|
|
1644
|
-
*
|
|
1491
|
+
* This error indicates problem with parsing of CSV
|
|
1645
1492
|
*
|
|
1646
|
-
* @
|
|
1647
|
-
* @returns @@@
|
|
1648
|
-
* @public exported from `@promptbook/utils`
|
|
1493
|
+
* @public exported from `@promptbook/core`
|
|
1649
1494
|
*/
|
|
1650
|
-
function
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1495
|
+
var CsvFormatError = /** @class */ (function (_super) {
|
|
1496
|
+
__extends(CsvFormatError, _super);
|
|
1497
|
+
function CsvFormatError(message) {
|
|
1498
|
+
var _this = _super.call(this, message) || this;
|
|
1499
|
+
_this.name = 'CsvFormatError';
|
|
1500
|
+
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
1501
|
+
return _this;
|
|
1502
|
+
}
|
|
1503
|
+
return CsvFormatError;
|
|
1504
|
+
}(AbstractFormatError));
|
|
1505
|
+
|
|
1656
1506
|
/**
|
|
1657
|
-
*
|
|
1507
|
+
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
1508
|
+
*
|
|
1509
|
+
* @public exported from `@promptbook/core`
|
|
1658
1510
|
*/
|
|
1511
|
+
var CollectionError = /** @class */ (function (_super) {
|
|
1512
|
+
__extends(CollectionError, _super);
|
|
1513
|
+
function CollectionError(message) {
|
|
1514
|
+
var _this = _super.call(this, message) || this;
|
|
1515
|
+
_this.name = 'CollectionError';
|
|
1516
|
+
Object.setPrototypeOf(_this, CollectionError.prototype);
|
|
1517
|
+
return _this;
|
|
1518
|
+
}
|
|
1519
|
+
return CollectionError;
|
|
1520
|
+
}(Error));
|
|
1659
1521
|
|
|
1660
1522
|
/**
|
|
1661
|
-
*
|
|
1523
|
+
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
1662
1524
|
*
|
|
1663
|
-
* @
|
|
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`
|
|
1808
|
-
*/
|
|
1809
|
-
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
1810
|
-
__extends(PipelineExecutionError, _super);
|
|
1811
|
-
function PipelineExecutionError(message) {
|
|
1812
|
-
var _this = _super.call(this, message) || this;
|
|
1813
|
-
_this.name = 'PipelineExecutionError';
|
|
1814
|
-
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
1815
|
-
return _this;
|
|
1816
|
-
}
|
|
1817
|
-
return PipelineExecutionError;
|
|
1818
|
-
}(Error));
|
|
1819
|
-
|
|
1820
|
-
/**
|
|
1821
|
-
* This error indicates problems parsing the format value
|
|
1822
|
-
*
|
|
1823
|
-
* For example, when the format value is not a valid JSON or CSV
|
|
1824
|
-
* This is not thrown directly but in extended classes
|
|
1825
|
-
*
|
|
1826
|
-
* @public exported from `@promptbook/core`
|
|
1827
|
-
*/
|
|
1828
|
-
var AbstractFormatError = /** @class */ (function (_super) {
|
|
1829
|
-
__extends(AbstractFormatError, _super);
|
|
1830
|
-
// Note: To allow instanceof do not put here error `name`
|
|
1831
|
-
// public readonly name = 'AbstractFormatError';
|
|
1832
|
-
function AbstractFormatError(message) {
|
|
1833
|
-
var _this = _super.call(this, message) || this;
|
|
1834
|
-
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
1835
|
-
return _this;
|
|
1836
|
-
}
|
|
1837
|
-
return AbstractFormatError;
|
|
1838
|
-
}(Error));
|
|
1839
|
-
|
|
1840
|
-
/**
|
|
1841
|
-
* This error indicates problem with parsing of CSV
|
|
1842
|
-
*
|
|
1843
|
-
* @public exported from `@promptbook/core`
|
|
1844
|
-
*/
|
|
1845
|
-
var CsvFormatError = /** @class */ (function (_super) {
|
|
1846
|
-
__extends(CsvFormatError, _super);
|
|
1847
|
-
function CsvFormatError(message) {
|
|
1848
|
-
var _this = _super.call(this, message) || this;
|
|
1849
|
-
_this.name = 'CsvFormatError';
|
|
1850
|
-
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
1851
|
-
return _this;
|
|
1852
|
-
}
|
|
1853
|
-
return CsvFormatError;
|
|
1854
|
-
}(AbstractFormatError));
|
|
1855
|
-
|
|
1856
|
-
/**
|
|
1857
|
-
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
1858
|
-
*
|
|
1859
|
-
* @public exported from `@promptbook/core`
|
|
1860
|
-
*/
|
|
1861
|
-
var CollectionError = /** @class */ (function (_super) {
|
|
1862
|
-
__extends(CollectionError, _super);
|
|
1863
|
-
function CollectionError(message) {
|
|
1864
|
-
var _this = _super.call(this, message) || this;
|
|
1865
|
-
_this.name = 'CollectionError';
|
|
1866
|
-
Object.setPrototypeOf(_this, CollectionError.prototype);
|
|
1867
|
-
return _this;
|
|
1868
|
-
}
|
|
1869
|
-
return CollectionError;
|
|
1870
|
-
}(Error));
|
|
1871
|
-
|
|
1872
|
-
/**
|
|
1873
|
-
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
1874
|
-
*
|
|
1875
|
-
* @public exported from `@promptbook/core`
|
|
1525
|
+
* @public exported from `@promptbook/core`
|
|
1876
1526
|
*/
|
|
1877
1527
|
var EnvironmentMismatchError = /** @class */ (function (_super) {
|
|
1878
1528
|
__extends(EnvironmentMismatchError, _super);
|
|
@@ -2918,148 +2568,471 @@ var $Register = /** @class */ (function () {
|
|
|
2918
2568
|
return $Register;
|
|
2919
2569
|
}());
|
|
2920
2570
|
|
|
2921
|
-
/**
|
|
2922
|
-
* @@@
|
|
2923
|
-
*
|
|
2924
|
-
* Note: `$` is used to indicate that this interacts with the global scope
|
|
2925
|
-
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
2926
|
-
* @public exported from `@promptbook/core`
|
|
2927
|
-
*/
|
|
2928
|
-
var $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
2929
|
-
/**
|
|
2930
|
-
* TODO: [®] DRY Register logic
|
|
2931
|
-
*/
|
|
2571
|
+
/**
|
|
2572
|
+
* @@@
|
|
2573
|
+
*
|
|
2574
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
2575
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
2576
|
+
* @public exported from `@promptbook/core`
|
|
2577
|
+
*/
|
|
2578
|
+
var $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
2579
|
+
/**
|
|
2580
|
+
* TODO: [®] DRY Register logic
|
|
2581
|
+
*/
|
|
2582
|
+
|
|
2583
|
+
/**
|
|
2584
|
+
* @@@
|
|
2585
|
+
*
|
|
2586
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
2587
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
2588
|
+
* @public exported from `@promptbook/core`
|
|
2589
|
+
*/
|
|
2590
|
+
var $scrapersRegister = new $Register('scraper_constructors');
|
|
2591
|
+
/**
|
|
2592
|
+
* TODO: [®] DRY Register logic
|
|
2593
|
+
*/
|
|
2594
|
+
|
|
2595
|
+
/**
|
|
2596
|
+
* Creates a message with all registered scrapers
|
|
2597
|
+
*
|
|
2598
|
+
* Note: This function is used to create a (error) message when there is no scraper for particular mime type
|
|
2599
|
+
*
|
|
2600
|
+
* @private internal function of `createScrapersFromConfiguration` and `createScrapersFromEnv`
|
|
2601
|
+
*/
|
|
2602
|
+
function $registeredScrapersMessage(availableScrapers) {
|
|
2603
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
2604
|
+
/**
|
|
2605
|
+
* Mixes registered scrapers from $scrapersMetadataRegister and $scrapersRegister
|
|
2606
|
+
*/
|
|
2607
|
+
var all = [];
|
|
2608
|
+
var _loop_1 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
|
|
2609
|
+
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
2610
|
+
return "continue";
|
|
2611
|
+
}
|
|
2612
|
+
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
2613
|
+
};
|
|
2614
|
+
try {
|
|
2615
|
+
for (var _d = __values($scrapersMetadataRegister.list()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
2616
|
+
var _f = _e.value, packageName = _f.packageName, className = _f.className, mimeTypes = _f.mimeTypes, documentationUrl = _f.documentationUrl, isAvilableInBrowser = _f.isAvilableInBrowser;
|
|
2617
|
+
_loop_1(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2621
|
+
finally {
|
|
2622
|
+
try {
|
|
2623
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
2624
|
+
}
|
|
2625
|
+
finally { if (e_1) throw e_1.error; }
|
|
2626
|
+
}
|
|
2627
|
+
var _loop_2 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
|
|
2628
|
+
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
2629
|
+
return "continue";
|
|
2630
|
+
}
|
|
2631
|
+
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
2632
|
+
};
|
|
2633
|
+
try {
|
|
2634
|
+
for (var _g = __values($scrapersRegister.list()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2635
|
+
var _j = _h.value, packageName = _j.packageName, className = _j.className, mimeTypes = _j.mimeTypes, documentationUrl = _j.documentationUrl, isAvilableInBrowser = _j.isAvilableInBrowser;
|
|
2636
|
+
_loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2640
|
+
finally {
|
|
2641
|
+
try {
|
|
2642
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
2643
|
+
}
|
|
2644
|
+
finally { if (e_2) throw e_2.error; }
|
|
2645
|
+
}
|
|
2646
|
+
try {
|
|
2647
|
+
for (var availableScrapers_1 = __values(availableScrapers), availableScrapers_1_1 = availableScrapers_1.next(); !availableScrapers_1_1.done; availableScrapers_1_1 = availableScrapers_1.next()) {
|
|
2648
|
+
var metadata_1 = availableScrapers_1_1.value.metadata;
|
|
2649
|
+
all.push(metadata_1);
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
2653
|
+
finally {
|
|
2654
|
+
try {
|
|
2655
|
+
if (availableScrapers_1_1 && !availableScrapers_1_1.done && (_c = availableScrapers_1.return)) _c.call(availableScrapers_1);
|
|
2656
|
+
}
|
|
2657
|
+
finally { if (e_3) throw e_3.error; }
|
|
2658
|
+
}
|
|
2659
|
+
var metadata = all.map(function (metadata) {
|
|
2660
|
+
var isMetadataAviailable = $scrapersMetadataRegister
|
|
2661
|
+
.list()
|
|
2662
|
+
.find(function (_a) {
|
|
2663
|
+
var packageName = _a.packageName, className = _a.className;
|
|
2664
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
2665
|
+
});
|
|
2666
|
+
var isInstalled = $scrapersRegister
|
|
2667
|
+
.list()
|
|
2668
|
+
.find(function (_a) {
|
|
2669
|
+
var packageName = _a.packageName, className = _a.className;
|
|
2670
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
2671
|
+
});
|
|
2672
|
+
var isAvilableInTools = availableScrapers.some(function (_a) {
|
|
2673
|
+
var _b = _a.metadata, packageName = _b.packageName, className = _b.className;
|
|
2674
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
2675
|
+
});
|
|
2676
|
+
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
|
|
2677
|
+
});
|
|
2678
|
+
if (metadata.length === 0) {
|
|
2679
|
+
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 ");
|
|
2680
|
+
}
|
|
2681
|
+
return spaceTrim$1(function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
|
|
2682
|
+
.map(function (_a, i) {
|
|
2683
|
+
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
|
|
2684
|
+
var more = [];
|
|
2685
|
+
// TODO: [🧠] Maybe use `documentationUrl`
|
|
2686
|
+
if (isMetadataAviailable) {
|
|
2687
|
+
more.push("\u2B1C Metadata registered");
|
|
2688
|
+
} // not else
|
|
2689
|
+
if (isInstalled) {
|
|
2690
|
+
more.push("\uD83D\uDFE9 Installed");
|
|
2691
|
+
} // not else
|
|
2692
|
+
if (isAvilableInTools) {
|
|
2693
|
+
more.push("\uD83D\uDFE6 Available in tools");
|
|
2694
|
+
} // not else
|
|
2695
|
+
if (!isMetadataAviailable && isInstalled) {
|
|
2696
|
+
more.push("When no metadata registered but scraper is installed, it is an unexpected behavior");
|
|
2697
|
+
} // not else
|
|
2698
|
+
if (!isInstalled && isAvilableInTools) {
|
|
2699
|
+
more.push("When the scraper is not installed but available in tools, it is an unexpected compatibility behavior");
|
|
2700
|
+
} // not else
|
|
2701
|
+
if (!isAvilableInBrowser) {
|
|
2702
|
+
more.push("Not usable in browser");
|
|
2703
|
+
}
|
|
2704
|
+
var moreText = more.length === 0 ? '' : " *(".concat(more.join('; '), ")*");
|
|
2705
|
+
return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes
|
|
2706
|
+
.map(function (mimeType) { return "\"".concat(mimeType, "\""); })
|
|
2707
|
+
.join(', ')).concat(moreText);
|
|
2708
|
+
})
|
|
2709
|
+
.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 "); });
|
|
2710
|
+
}
|
|
2711
|
+
/**
|
|
2712
|
+
* TODO: [®] DRY Register logic
|
|
2713
|
+
*/
|
|
2714
|
+
|
|
2715
|
+
var defaultDiacriticsRemovalMap = [
|
|
2716
|
+
{
|
|
2717
|
+
base: 'A',
|
|
2718
|
+
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',
|
|
2719
|
+
},
|
|
2720
|
+
{ base: 'AA', letters: '\uA732' },
|
|
2721
|
+
{ base: 'AE', letters: '\u00C6\u01FC\u01E2' },
|
|
2722
|
+
{ base: 'AO', letters: '\uA734' },
|
|
2723
|
+
{ base: 'AU', letters: '\uA736' },
|
|
2724
|
+
{ base: 'AV', letters: '\uA738\uA73A' },
|
|
2725
|
+
{ base: 'AY', letters: '\uA73C' },
|
|
2726
|
+
{
|
|
2727
|
+
base: 'B',
|
|
2728
|
+
letters: '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181',
|
|
2729
|
+
},
|
|
2730
|
+
{
|
|
2731
|
+
base: 'C',
|
|
2732
|
+
letters: '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E',
|
|
2733
|
+
},
|
|
2734
|
+
{
|
|
2735
|
+
base: 'D',
|
|
2736
|
+
letters: '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0',
|
|
2737
|
+
},
|
|
2738
|
+
{ base: 'DZ', letters: '\u01F1\u01C4' },
|
|
2739
|
+
{ base: 'Dz', letters: '\u01F2\u01C5' },
|
|
2740
|
+
{
|
|
2741
|
+
base: 'E',
|
|
2742
|
+
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',
|
|
2743
|
+
},
|
|
2744
|
+
{ base: 'F', letters: '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' },
|
|
2745
|
+
{
|
|
2746
|
+
base: 'G',
|
|
2747
|
+
letters: '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E',
|
|
2748
|
+
},
|
|
2749
|
+
{
|
|
2750
|
+
base: 'H',
|
|
2751
|
+
letters: '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D',
|
|
2752
|
+
},
|
|
2753
|
+
{
|
|
2754
|
+
base: 'I',
|
|
2755
|
+
letters: '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197',
|
|
2756
|
+
},
|
|
2757
|
+
{ base: 'J', letters: '\u004A\u24BF\uFF2A\u0134\u0248' },
|
|
2758
|
+
{
|
|
2759
|
+
base: 'K',
|
|
2760
|
+
letters: '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2',
|
|
2761
|
+
},
|
|
2762
|
+
{
|
|
2763
|
+
base: 'L',
|
|
2764
|
+
letters: '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780',
|
|
2765
|
+
},
|
|
2766
|
+
{ base: 'LJ', letters: '\u01C7' },
|
|
2767
|
+
{ base: 'Lj', letters: '\u01C8' },
|
|
2768
|
+
{ base: 'M', letters: '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' },
|
|
2769
|
+
{
|
|
2770
|
+
base: 'N',
|
|
2771
|
+
letters: '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4',
|
|
2772
|
+
},
|
|
2773
|
+
{ base: 'NJ', letters: '\u01CA' },
|
|
2774
|
+
{ base: 'Nj', letters: '\u01CB' },
|
|
2775
|
+
{
|
|
2776
|
+
base: 'O',
|
|
2777
|
+
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',
|
|
2778
|
+
},
|
|
2779
|
+
{ base: 'OI', letters: '\u01A2' },
|
|
2780
|
+
{ base: 'OO', letters: '\uA74E' },
|
|
2781
|
+
{ base: 'OU', letters: '\u0222' },
|
|
2782
|
+
{ base: 'OE', letters: '\u008C\u0152' },
|
|
2783
|
+
{ base: 'oe', letters: '\u009C\u0153' },
|
|
2784
|
+
{
|
|
2785
|
+
base: 'P',
|
|
2786
|
+
letters: '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754',
|
|
2787
|
+
},
|
|
2788
|
+
{ base: 'Q', letters: '\u0051\u24C6\uFF31\uA756\uA758\u024A' },
|
|
2789
|
+
{
|
|
2790
|
+
base: 'R',
|
|
2791
|
+
letters: '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782',
|
|
2792
|
+
},
|
|
2793
|
+
{
|
|
2794
|
+
base: 'S',
|
|
2795
|
+
letters: '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784',
|
|
2796
|
+
},
|
|
2797
|
+
{
|
|
2798
|
+
base: 'T',
|
|
2799
|
+
letters: '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786',
|
|
2800
|
+
},
|
|
2801
|
+
{ base: 'TZ', letters: '\uA728' },
|
|
2802
|
+
{
|
|
2803
|
+
base: 'U',
|
|
2804
|
+
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',
|
|
2805
|
+
},
|
|
2806
|
+
{ base: 'V', letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' },
|
|
2807
|
+
{ base: 'VY', letters: '\uA760' },
|
|
2808
|
+
{
|
|
2809
|
+
base: 'W',
|
|
2810
|
+
letters: '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72',
|
|
2811
|
+
},
|
|
2812
|
+
{ base: 'X', letters: '\u0058\u24CD\uFF38\u1E8A\u1E8C' },
|
|
2813
|
+
{
|
|
2814
|
+
base: 'Y',
|
|
2815
|
+
letters: '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE',
|
|
2816
|
+
},
|
|
2817
|
+
{
|
|
2818
|
+
base: 'Z',
|
|
2819
|
+
letters: '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762',
|
|
2820
|
+
},
|
|
2821
|
+
{
|
|
2822
|
+
base: 'a',
|
|
2823
|
+
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',
|
|
2824
|
+
},
|
|
2825
|
+
{ base: 'aa', letters: '\uA733' },
|
|
2826
|
+
{ base: 'ae', letters: '\u00E6\u01FD\u01E3' },
|
|
2827
|
+
{ base: 'ao', letters: '\uA735' },
|
|
2828
|
+
{ base: 'au', letters: '\uA737' },
|
|
2829
|
+
{ base: 'av', letters: '\uA739\uA73B' },
|
|
2830
|
+
{ base: 'ay', letters: '\uA73D' },
|
|
2831
|
+
{
|
|
2832
|
+
base: 'b',
|
|
2833
|
+
letters: '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253',
|
|
2834
|
+
},
|
|
2835
|
+
{
|
|
2836
|
+
base: 'c',
|
|
2837
|
+
letters: '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184',
|
|
2838
|
+
},
|
|
2839
|
+
{
|
|
2840
|
+
base: 'd',
|
|
2841
|
+
letters: '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A',
|
|
2842
|
+
},
|
|
2843
|
+
{ base: 'dz', letters: '\u01F3\u01C6' },
|
|
2844
|
+
{
|
|
2845
|
+
base: 'e',
|
|
2846
|
+
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',
|
|
2847
|
+
},
|
|
2848
|
+
{ base: 'f', letters: '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' },
|
|
2849
|
+
{
|
|
2850
|
+
base: 'g',
|
|
2851
|
+
letters: '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F',
|
|
2852
|
+
},
|
|
2853
|
+
{
|
|
2854
|
+
base: 'h',
|
|
2855
|
+
letters: '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265',
|
|
2856
|
+
},
|
|
2857
|
+
{ base: 'hv', letters: '\u0195' },
|
|
2858
|
+
{
|
|
2859
|
+
base: 'i',
|
|
2860
|
+
letters: '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131',
|
|
2861
|
+
},
|
|
2862
|
+
{ base: 'j', letters: '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' },
|
|
2863
|
+
{
|
|
2864
|
+
base: 'k',
|
|
2865
|
+
letters: '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3',
|
|
2866
|
+
},
|
|
2867
|
+
{
|
|
2868
|
+
base: 'l',
|
|
2869
|
+
letters: '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747',
|
|
2870
|
+
},
|
|
2871
|
+
{ base: 'lj', letters: '\u01C9' },
|
|
2872
|
+
{ base: 'm', letters: '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' },
|
|
2873
|
+
{
|
|
2874
|
+
base: 'n',
|
|
2875
|
+
letters: '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5',
|
|
2876
|
+
},
|
|
2877
|
+
{ base: 'nj', letters: '\u01CC' },
|
|
2878
|
+
{
|
|
2879
|
+
base: 'o',
|
|
2880
|
+
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',
|
|
2881
|
+
},
|
|
2882
|
+
{ base: 'oi', letters: '\u01A3' },
|
|
2883
|
+
{ base: 'ou', letters: '\u0223' },
|
|
2884
|
+
{ base: 'oo', letters: '\uA74F' },
|
|
2885
|
+
{
|
|
2886
|
+
base: 'p',
|
|
2887
|
+
letters: '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755',
|
|
2888
|
+
},
|
|
2889
|
+
{ base: 'q', letters: '\u0071\u24E0\uFF51\u024B\uA757\uA759' },
|
|
2890
|
+
{
|
|
2891
|
+
base: 'r',
|
|
2892
|
+
letters: '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783',
|
|
2893
|
+
},
|
|
2894
|
+
{
|
|
2895
|
+
base: 's',
|
|
2896
|
+
letters: '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B',
|
|
2897
|
+
},
|
|
2898
|
+
{
|
|
2899
|
+
base: 't',
|
|
2900
|
+
letters: '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787',
|
|
2901
|
+
},
|
|
2902
|
+
{ base: 'tz', letters: '\uA729' },
|
|
2903
|
+
{
|
|
2904
|
+
base: 'u',
|
|
2905
|
+
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',
|
|
2906
|
+
},
|
|
2907
|
+
{ base: 'v', letters: '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' },
|
|
2908
|
+
{ base: 'vy', letters: '\uA761' },
|
|
2909
|
+
{
|
|
2910
|
+
base: 'w',
|
|
2911
|
+
letters: '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73',
|
|
2912
|
+
},
|
|
2913
|
+
{ base: 'x', letters: '\u0078\u24E7\uFF58\u1E8B\u1E8D' },
|
|
2914
|
+
{
|
|
2915
|
+
base: 'y',
|
|
2916
|
+
letters: '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF',
|
|
2917
|
+
},
|
|
2918
|
+
{
|
|
2919
|
+
base: 'z',
|
|
2920
|
+
letters: '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763',
|
|
2921
|
+
},
|
|
2922
|
+
];
|
|
2923
|
+
/**
|
|
2924
|
+
* Map of letters from diacritic variant to diacritless variant
|
|
2925
|
+
* Contains lowercase and uppercase separatelly
|
|
2926
|
+
*
|
|
2927
|
+
* > "á" => "a"
|
|
2928
|
+
* > "ě" => "e"
|
|
2929
|
+
* > "Ă" => "A"
|
|
2930
|
+
* > ...
|
|
2931
|
+
*
|
|
2932
|
+
* @public exported from `@promptbook/utils`
|
|
2933
|
+
*/
|
|
2934
|
+
var DIACRITIC_VARIANTS_LETTERS = {};
|
|
2935
|
+
// tslint:disable-next-line: prefer-for-of
|
|
2936
|
+
for (var i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
2937
|
+
var letters = defaultDiacriticsRemovalMap[i].letters;
|
|
2938
|
+
// tslint:disable-next-line: prefer-for-of
|
|
2939
|
+
for (var j = 0; j < letters.length; j++) {
|
|
2940
|
+
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
// <- TODO: [🍓] Put to maker function to save execution time if not needed
|
|
2944
|
+
/*
|
|
2945
|
+
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
2946
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
2947
|
+
you may not use this file except in compliance with the License.
|
|
2948
|
+
You may obtain a copy of the License at
|
|
2949
|
+
|
|
2950
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
2951
|
+
|
|
2952
|
+
Unless required by applicable law or agreed to in writing, software
|
|
2953
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
2954
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2955
|
+
See the License for the specific language governing permissions and
|
|
2956
|
+
limitations under the License.
|
|
2957
|
+
*/
|
|
2932
2958
|
|
|
2933
2959
|
/**
|
|
2934
2960
|
* @@@
|
|
2935
2961
|
*
|
|
2936
|
-
*
|
|
2937
|
-
* @
|
|
2938
|
-
* @public exported from `@promptbook/
|
|
2962
|
+
* @param input @@@
|
|
2963
|
+
* @returns @@@
|
|
2964
|
+
* @public exported from `@promptbook/utils`
|
|
2939
2965
|
*/
|
|
2940
|
-
|
|
2966
|
+
function removeDiacritics(input) {
|
|
2967
|
+
/*eslint no-control-regex: "off"*/
|
|
2968
|
+
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
2969
|
+
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
2970
|
+
});
|
|
2971
|
+
}
|
|
2941
2972
|
/**
|
|
2942
|
-
* TODO: [
|
|
2973
|
+
* TODO: [Ж] Variant for cyrillic (and in general non-latin) letters
|
|
2943
2974
|
*/
|
|
2944
2975
|
|
|
2945
2976
|
/**
|
|
2946
|
-
*
|
|
2947
|
-
*
|
|
2948
|
-
* Note: This function is used to create a (error) message when there is no scraper for particular mime type
|
|
2977
|
+
* @@@
|
|
2949
2978
|
*
|
|
2950
|
-
* @
|
|
2979
|
+
* @param text @@@
|
|
2980
|
+
* @returns @@@
|
|
2981
|
+
* @example 'hello-world'
|
|
2982
|
+
* @example 'i-love-promptbook'
|
|
2983
|
+
* @public exported from `@promptbook/utils`
|
|
2951
2984
|
*/
|
|
2952
|
-
function
|
|
2953
|
-
var e_1, _a
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
var
|
|
2958
|
-
var _loop_1 = function (packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser) {
|
|
2959
|
-
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
2960
|
-
return "continue";
|
|
2961
|
-
}
|
|
2962
|
-
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
2963
|
-
};
|
|
2985
|
+
function normalizeToKebabCase(text) {
|
|
2986
|
+
var e_1, _a;
|
|
2987
|
+
text = removeDiacritics(text);
|
|
2988
|
+
var charType;
|
|
2989
|
+
var lastCharType = 'OTHER';
|
|
2990
|
+
var normalizedName = '';
|
|
2964
2991
|
try {
|
|
2965
|
-
for (var
|
|
2966
|
-
var
|
|
2967
|
-
|
|
2992
|
+
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
2993
|
+
var char = text_1_1.value;
|
|
2994
|
+
var normalizedChar = void 0;
|
|
2995
|
+
if (/^[a-z]$/.test(char)) {
|
|
2996
|
+
charType = 'LOWERCASE';
|
|
2997
|
+
normalizedChar = char;
|
|
2998
|
+
}
|
|
2999
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
3000
|
+
charType = 'UPPERCASE';
|
|
3001
|
+
normalizedChar = char.toLowerCase();
|
|
3002
|
+
}
|
|
3003
|
+
else if (/^[0-9]$/.test(char)) {
|
|
3004
|
+
charType = 'NUMBER';
|
|
3005
|
+
normalizedChar = char;
|
|
3006
|
+
}
|
|
3007
|
+
else {
|
|
3008
|
+
charType = 'OTHER';
|
|
3009
|
+
normalizedChar = '-';
|
|
3010
|
+
}
|
|
3011
|
+
if (charType !== lastCharType &&
|
|
3012
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
3013
|
+
!(lastCharType === 'NUMBER') &&
|
|
3014
|
+
!(charType === 'NUMBER')) {
|
|
3015
|
+
normalizedName += '-';
|
|
3016
|
+
}
|
|
3017
|
+
normalizedName += normalizedChar;
|
|
3018
|
+
lastCharType = charType;
|
|
2968
3019
|
}
|
|
2969
3020
|
}
|
|
2970
3021
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2971
3022
|
finally {
|
|
2972
3023
|
try {
|
|
2973
|
-
if (
|
|
3024
|
+
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
2974
3025
|
}
|
|
2975
3026
|
finally { if (e_1) throw e_1.error; }
|
|
2976
3027
|
}
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
};
|
|
2983
|
-
try {
|
|
2984
|
-
for (var _g = __values($scrapersRegister.list()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2985
|
-
var _j = _h.value, packageName = _j.packageName, className = _j.className, mimeTypes = _j.mimeTypes, documentationUrl = _j.documentationUrl, isAvilableInBrowser = _j.isAvilableInBrowser;
|
|
2986
|
-
_loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2990
|
-
finally {
|
|
2991
|
-
try {
|
|
2992
|
-
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
2993
|
-
}
|
|
2994
|
-
finally { if (e_2) throw e_2.error; }
|
|
2995
|
-
}
|
|
2996
|
-
try {
|
|
2997
|
-
for (var availableScrapers_1 = __values(availableScrapers), availableScrapers_1_1 = availableScrapers_1.next(); !availableScrapers_1_1.done; availableScrapers_1_1 = availableScrapers_1.next()) {
|
|
2998
|
-
var metadata_1 = availableScrapers_1_1.value.metadata;
|
|
2999
|
-
all.push(metadata_1);
|
|
3000
|
-
}
|
|
3001
|
-
}
|
|
3002
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
3003
|
-
finally {
|
|
3004
|
-
try {
|
|
3005
|
-
if (availableScrapers_1_1 && !availableScrapers_1_1.done && (_c = availableScrapers_1.return)) _c.call(availableScrapers_1);
|
|
3006
|
-
}
|
|
3007
|
-
finally { if (e_3) throw e_3.error; }
|
|
3008
|
-
}
|
|
3009
|
-
var metadata = all.map(function (metadata) {
|
|
3010
|
-
var isMetadataAviailable = $scrapersMetadataRegister
|
|
3011
|
-
.list()
|
|
3012
|
-
.find(function (_a) {
|
|
3013
|
-
var packageName = _a.packageName, className = _a.className;
|
|
3014
|
-
return metadata.packageName === packageName && metadata.className === className;
|
|
3015
|
-
});
|
|
3016
|
-
var isInstalled = $scrapersRegister
|
|
3017
|
-
.list()
|
|
3018
|
-
.find(function (_a) {
|
|
3019
|
-
var packageName = _a.packageName, className = _a.className;
|
|
3020
|
-
return metadata.packageName === packageName && metadata.className === className;
|
|
3021
|
-
});
|
|
3022
|
-
var isAvilableInTools = availableScrapers.some(function (_a) {
|
|
3023
|
-
var _b = _a.metadata, packageName = _b.packageName, className = _b.className;
|
|
3024
|
-
return metadata.packageName === packageName && metadata.className === className;
|
|
3025
|
-
});
|
|
3026
|
-
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
|
|
3027
|
-
});
|
|
3028
|
-
if (metadata.length === 0) {
|
|
3029
|
-
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 ");
|
|
3030
|
-
}
|
|
3031
|
-
return spaceTrim$1(function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
|
|
3032
|
-
.map(function (_a, i) {
|
|
3033
|
-
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
|
|
3034
|
-
var more = [];
|
|
3035
|
-
// TODO: [🧠] Maybe use `documentationUrl`
|
|
3036
|
-
if (isMetadataAviailable) {
|
|
3037
|
-
more.push("\u2B1C Metadata registered");
|
|
3038
|
-
} // not else
|
|
3039
|
-
if (isInstalled) {
|
|
3040
|
-
more.push("\uD83D\uDFE9 Installed");
|
|
3041
|
-
} // not else
|
|
3042
|
-
if (isAvilableInTools) {
|
|
3043
|
-
more.push("\uD83D\uDFE6 Available in tools");
|
|
3044
|
-
} // not else
|
|
3045
|
-
if (!isMetadataAviailable && isInstalled) {
|
|
3046
|
-
more.push("When no metadata registered but scraper is installed, it is an unexpected behavior");
|
|
3047
|
-
} // not else
|
|
3048
|
-
if (!isInstalled && isAvilableInTools) {
|
|
3049
|
-
more.push("When the scraper is not installed but available in tools, it is an unexpected compatibility behavior");
|
|
3050
|
-
} // not else
|
|
3051
|
-
if (!isAvilableInBrowser) {
|
|
3052
|
-
more.push("Not usable in browser");
|
|
3053
|
-
}
|
|
3054
|
-
var moreText = more.length === 0 ? '' : " *(".concat(more.join('; '), ")*");
|
|
3055
|
-
return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes
|
|
3056
|
-
.map(function (mimeType) { return "\"".concat(mimeType, "\""); })
|
|
3057
|
-
.join(', ')).concat(moreText);
|
|
3058
|
-
})
|
|
3059
|
-
.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 "); });
|
|
3028
|
+
normalizedName = normalizedName.split(/-+/g).join('-');
|
|
3029
|
+
normalizedName = normalizedName.split(/-?\/-?/g).join('/');
|
|
3030
|
+
normalizedName = normalizedName.replace(/^-/, '');
|
|
3031
|
+
normalizedName = normalizedName.replace(/-$/, '');
|
|
3032
|
+
return normalizedName;
|
|
3060
3033
|
}
|
|
3061
3034
|
/**
|
|
3062
|
-
*
|
|
3035
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3063
3036
|
*/
|
|
3064
3037
|
|
|
3065
3038
|
/**
|
|
@@ -3138,6 +3111,32 @@ function isFileExisting(filename, fs) {
|
|
|
3138
3111
|
* TODO: [🖇] What about symlinks?
|
|
3139
3112
|
*/
|
|
3140
3113
|
|
|
3114
|
+
/**
|
|
3115
|
+
* Tests if given string is valid URL.
|
|
3116
|
+
*
|
|
3117
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
3118
|
+
* @public exported from `@promptbook/utils`
|
|
3119
|
+
*/
|
|
3120
|
+
function isValidFilePath(filename) {
|
|
3121
|
+
if (typeof filename !== 'string') {
|
|
3122
|
+
return false;
|
|
3123
|
+
}
|
|
3124
|
+
var filenameSlashes = filename.split('\\').join('/');
|
|
3125
|
+
// Absolute Unix path: /hello.txt
|
|
3126
|
+
if (/^(\/)/i.test(filenameSlashes)) {
|
|
3127
|
+
return true;
|
|
3128
|
+
}
|
|
3129
|
+
// Absolute Windows path: /hello.txt
|
|
3130
|
+
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
3131
|
+
return true;
|
|
3132
|
+
}
|
|
3133
|
+
// Relative path: ./hello.txt
|
|
3134
|
+
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
3135
|
+
return true;
|
|
3136
|
+
}
|
|
3137
|
+
return false;
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3141
3140
|
/**
|
|
3142
3141
|
* @@@
|
|
3143
3142
|
*
|
|
@@ -3599,10 +3598,11 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3599
3598
|
* @param script from which to extract the variables
|
|
3600
3599
|
* @returns the list of variable names
|
|
3601
3600
|
* @throws {ParseError} if the script is invalid
|
|
3602
|
-
* @public exported from `@promptbook/utils`
|
|
3601
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
3603
3602
|
*/
|
|
3604
|
-
function
|
|
3603
|
+
function extractVariablesFromScript(script) {
|
|
3605
3604
|
var variables = new Set();
|
|
3605
|
+
var originalScript = script;
|
|
3606
3606
|
script = "(()=>{".concat(script, "})()");
|
|
3607
3607
|
try {
|
|
3608
3608
|
for (var i = 0; i < 100 /* <- TODO: This limit to configuration */; i++)
|
|
@@ -3634,7 +3634,9 @@ function extractVariables(script) {
|
|
|
3634
3634
|
if (!(error instanceof Error)) {
|
|
3635
3635
|
throw error;
|
|
3636
3636
|
}
|
|
3637
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n
|
|
3637
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n\n\n Found variables:\n\n ").concat(Array.from(variables)
|
|
3638
|
+
.map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
|
|
3639
|
+
.join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
|
|
3638
3640
|
}
|
|
3639
3641
|
return variables;
|
|
3640
3642
|
}
|
|
@@ -3648,7 +3650,7 @@ function extractVariables(script) {
|
|
|
3648
3650
|
* @param task the task with used parameters
|
|
3649
3651
|
* @returns the set of parameter names
|
|
3650
3652
|
* @throws {ParseError} if the script is invalid
|
|
3651
|
-
* @public exported from `@promptbook/
|
|
3653
|
+
* @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
|
|
3652
3654
|
*/
|
|
3653
3655
|
function extractParameterNamesFromTask(task) {
|
|
3654
3656
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
@@ -3669,7 +3671,7 @@ function extractParameterNamesFromTask(task) {
|
|
|
3669
3671
|
}
|
|
3670
3672
|
if (taskType === 'SCRIPT_TASK') {
|
|
3671
3673
|
try {
|
|
3672
|
-
for (var _g = __values(
|
|
3674
|
+
for (var _g = __values(extractVariablesFromScript(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
3673
3675
|
var parameterName = _h.value;
|
|
3674
3676
|
parameterNames.add(parameterName);
|
|
3675
3677
|
}
|
|
@@ -5578,6 +5580,46 @@ function createPipelineExecutor(options) {
|
|
|
5578
5580
|
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
5579
5581
|
*/
|
|
5580
5582
|
|
|
5583
|
+
/**
|
|
5584
|
+
* Removes emojis from a string and fix whitespaces
|
|
5585
|
+
*
|
|
5586
|
+
* @param text with emojis
|
|
5587
|
+
* @returns text without emojis
|
|
5588
|
+
* @public exported from `@promptbook/utils`
|
|
5589
|
+
*/
|
|
5590
|
+
function removeEmojis(text) {
|
|
5591
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
5592
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
5593
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
5594
|
+
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
5595
|
+
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
5596
|
+
return text;
|
|
5597
|
+
}
|
|
5598
|
+
|
|
5599
|
+
/**
|
|
5600
|
+
* @@@
|
|
5601
|
+
*
|
|
5602
|
+
* @param value @@@
|
|
5603
|
+
* @returns @@@
|
|
5604
|
+
* @example @@@
|
|
5605
|
+
* @public exported from `@promptbook/utils`
|
|
5606
|
+
*/
|
|
5607
|
+
function titleToName(value) {
|
|
5608
|
+
if (isValidUrl(value)) {
|
|
5609
|
+
value = value.replace(/^https?:\/\//, '');
|
|
5610
|
+
value = value.replace(/\.html$/, '');
|
|
5611
|
+
}
|
|
5612
|
+
else if (isValidFilePath(value)) {
|
|
5613
|
+
value = basename(value);
|
|
5614
|
+
// Note: Keeping extension in the name
|
|
5615
|
+
}
|
|
5616
|
+
value = value.split('/').join('-');
|
|
5617
|
+
value = removeEmojis(value);
|
|
5618
|
+
value = normalizeToKebabCase(value);
|
|
5619
|
+
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
5620
|
+
return value;
|
|
5621
|
+
}
|
|
5622
|
+
|
|
5581
5623
|
/**
|
|
5582
5624
|
* Metadata of the scraper
|
|
5583
5625
|
*
|