@promptbook/website-crawler 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 +74 -45
- 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 +74 -45
- 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/README.md
CHANGED
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
<blockquote style="color: #ff8811">
|
|
27
|
+
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
+
</blockquote>
|
|
29
|
+
|
|
26
30
|
## 📦 Package `@promptbook/website-crawler`
|
|
27
31
|
|
|
28
32
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -24,7 +24,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
24
24
|
*
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.77.
|
|
27
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.77.1';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -702,32 +702,12 @@ var KnowledgeScrapeError = /** @class */ (function (_super) {
|
|
|
702
702
|
}(Error));
|
|
703
703
|
|
|
704
704
|
/**
|
|
705
|
-
*
|
|
706
|
-
*
|
|
707
|
-
* Note: Dataurl are considered perfectly valid.
|
|
708
|
-
* Note: There are two simmilar functions:
|
|
709
|
-
* - `isValidUrl` which tests any URL
|
|
710
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
705
|
+
* @@@
|
|
711
706
|
*
|
|
712
|
-
* @
|
|
707
|
+
* @private for `FileCacheStorage`
|
|
713
708
|
*/
|
|
714
|
-
function
|
|
715
|
-
|
|
716
|
-
return false;
|
|
717
|
-
}
|
|
718
|
-
try {
|
|
719
|
-
if (url.startsWith('blob:')) {
|
|
720
|
-
url = url.replace(/^blob:/, '');
|
|
721
|
-
}
|
|
722
|
-
var urlObject = new URL(url /* because fail is handled */);
|
|
723
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
724
|
-
return false;
|
|
725
|
-
}
|
|
726
|
-
return true;
|
|
727
|
-
}
|
|
728
|
-
catch (error) {
|
|
729
|
-
return false;
|
|
730
|
-
}
|
|
709
|
+
function nameToSubfolderPath(name) {
|
|
710
|
+
return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
|
|
731
711
|
}
|
|
732
712
|
|
|
733
713
|
var defaultDiacriticsRemovalMap = [
|
|
@@ -1095,6 +1075,35 @@ function isValidFilePath(filename) {
|
|
|
1095
1075
|
return false;
|
|
1096
1076
|
}
|
|
1097
1077
|
|
|
1078
|
+
/**
|
|
1079
|
+
* Tests if given string is valid URL.
|
|
1080
|
+
*
|
|
1081
|
+
* Note: Dataurl are considered perfectly valid.
|
|
1082
|
+
* Note: There are two simmilar functions:
|
|
1083
|
+
* - `isValidUrl` which tests any URL
|
|
1084
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
1085
|
+
*
|
|
1086
|
+
* @public exported from `@promptbook/utils`
|
|
1087
|
+
*/
|
|
1088
|
+
function isValidUrl(url) {
|
|
1089
|
+
if (typeof url !== 'string') {
|
|
1090
|
+
return false;
|
|
1091
|
+
}
|
|
1092
|
+
try {
|
|
1093
|
+
if (url.startsWith('blob:')) {
|
|
1094
|
+
url = url.replace(/^blob:/, '');
|
|
1095
|
+
}
|
|
1096
|
+
var urlObject = new URL(url /* because fail is handled */);
|
|
1097
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
1098
|
+
return false;
|
|
1099
|
+
}
|
|
1100
|
+
return true;
|
|
1101
|
+
}
|
|
1102
|
+
catch (error) {
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1098
1107
|
/**
|
|
1099
1108
|
* @@@
|
|
1100
1109
|
*
|
|
@@ -1119,15 +1128,6 @@ function titleToName(value) {
|
|
|
1119
1128
|
return value;
|
|
1120
1129
|
}
|
|
1121
1130
|
|
|
1122
|
-
/**
|
|
1123
|
-
* @@@
|
|
1124
|
-
*
|
|
1125
|
-
* @private for `FileCacheStorage`
|
|
1126
|
-
*/
|
|
1127
|
-
function nameToSubfolderPath(name) {
|
|
1128
|
-
return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
1131
|
/**
|
|
1132
1132
|
* Create a filename for intermediate cache for scrapers
|
|
1133
1133
|
*
|
|
@@ -2190,7 +2190,7 @@ var LimitReachedError = /** @class */ (function (_super) {
|
|
|
2190
2190
|
*
|
|
2191
2191
|
* @public exported from `@promptbook/core`
|
|
2192
2192
|
*/
|
|
2193
|
-
var
|
|
2193
|
+
var PROMPTBOOK_ERRORS = {
|
|
2194
2194
|
AbstractFormatError: AbstractFormatError,
|
|
2195
2195
|
CsvFormatError: CsvFormatError,
|
|
2196
2196
|
CollectionError: CollectionError,
|
|
@@ -2208,6 +2208,35 @@ var ERRORS = {
|
|
|
2208
2208
|
UnexpectedError: UnexpectedError,
|
|
2209
2209
|
// TODO: [🪑]> VersionMismatchError,
|
|
2210
2210
|
};
|
|
2211
|
+
/**
|
|
2212
|
+
* Index of all javascript errors
|
|
2213
|
+
*
|
|
2214
|
+
* @private for internal usage
|
|
2215
|
+
*/
|
|
2216
|
+
var COMMON_JAVASCRIPT_ERRORS = {
|
|
2217
|
+
Error: Error,
|
|
2218
|
+
EvalError: EvalError,
|
|
2219
|
+
RangeError: RangeError,
|
|
2220
|
+
ReferenceError: ReferenceError,
|
|
2221
|
+
SyntaxError: SyntaxError,
|
|
2222
|
+
TypeError: TypeError,
|
|
2223
|
+
URIError: URIError,
|
|
2224
|
+
AggregateError: AggregateError,
|
|
2225
|
+
/*
|
|
2226
|
+
Note: Not widely supported
|
|
2227
|
+
> InternalError,
|
|
2228
|
+
> ModuleError,
|
|
2229
|
+
> HeapError,
|
|
2230
|
+
> WebAssemblyCompileError,
|
|
2231
|
+
> WebAssemblyRuntimeError,
|
|
2232
|
+
*/
|
|
2233
|
+
};
|
|
2234
|
+
/**
|
|
2235
|
+
* Index of all errors
|
|
2236
|
+
*
|
|
2237
|
+
* @private for internal usage
|
|
2238
|
+
*/
|
|
2239
|
+
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
2211
2240
|
/**
|
|
2212
2241
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2213
2242
|
*/
|
|
@@ -2218,11 +2247,11 @@ var ERRORS = {
|
|
|
2218
2247
|
* @public exported from `@promptbook/utils`
|
|
2219
2248
|
*/
|
|
2220
2249
|
function deserializeError(error) {
|
|
2221
|
-
|
|
2222
|
-
|
|
2250
|
+
var ErrorClass = ALL_ERRORS[error.name];
|
|
2251
|
+
if (ErrorClass === undefined) {
|
|
2252
|
+
return new Error("".concat(error.name, ": ").concat(error.message));
|
|
2223
2253
|
}
|
|
2224
|
-
|
|
2225
|
-
return new CustomError(error.message);
|
|
2254
|
+
return new ErrorClass(error.message);
|
|
2226
2255
|
}
|
|
2227
2256
|
|
|
2228
2257
|
/**
|
|
@@ -2296,8 +2325,8 @@ function isPipelinePrepared(pipeline) {
|
|
|
2296
2325
|
*/
|
|
2297
2326
|
function serializeError(error) {
|
|
2298
2327
|
var name = error.name, message = error.message, stack = error.stack;
|
|
2299
|
-
if (!
|
|
2300
|
-
|
|
2328
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2329
|
+
console.error(spaceTrim$1(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2301
2330
|
}
|
|
2302
2331
|
return {
|
|
2303
2332
|
name: name,
|
|
@@ -3668,9 +3697,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3668
3697
|
* @param script from which to extract the variables
|
|
3669
3698
|
* @returns the list of variable names
|
|
3670
3699
|
* @throws {ParseError} if the script is invalid
|
|
3671
|
-
* @public exported from `@promptbook/utils`
|
|
3700
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
3672
3701
|
*/
|
|
3673
|
-
function
|
|
3702
|
+
function extractVariablesFromScript(script) {
|
|
3674
3703
|
var variables = new Set();
|
|
3675
3704
|
script = "(()=>{".concat(script, "})()");
|
|
3676
3705
|
try {
|
|
@@ -3717,7 +3746,7 @@ function extractVariables(script) {
|
|
|
3717
3746
|
* @param task the task with used parameters
|
|
3718
3747
|
* @returns the set of parameter names
|
|
3719
3748
|
* @throws {ParseError} if the script is invalid
|
|
3720
|
-
* @public exported from `@promptbook/
|
|
3749
|
+
* @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
|
|
3721
3750
|
*/
|
|
3722
3751
|
function extractParameterNamesFromTask(task) {
|
|
3723
3752
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
@@ -3738,7 +3767,7 @@ function extractParameterNamesFromTask(task) {
|
|
|
3738
3767
|
}
|
|
3739
3768
|
if (taskType === 'SCRIPT_TASK') {
|
|
3740
3769
|
try {
|
|
3741
|
-
for (var _g = __values(
|
|
3770
|
+
for (var _g = __values(extractVariablesFromScript(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
3742
3771
|
var parameterName = _h.value;
|
|
3743
3772
|
parameterNames.add(parameterName);
|
|
3744
3773
|
}
|