@promptbook/node 0.75.3 → 0.75.5
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 +157 -120
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +6 -2
- package/esm/typings/src/config.d.ts +9 -1
- package/esm/typings/src/errors/0-BoilerplateError.d.ts +12 -0
- package/esm/typings/src/errors/{index.d.ts → 0-index.d.ts} +10 -2
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/register/$registeredScrapersMessage.d.ts +2 -1
- package/package.json +2 -2
- package/umd/index.umd.js +157 -120
- package/umd/index.umd.js.map +1 -1
|
@@ -24,6 +24,7 @@ import { DEFAULT_REMOTE_URL } from '../config';
|
|
|
24
24
|
import { DEFAULT_REMOTE_URL_PATH } from '../config';
|
|
25
25
|
import { DEFAULT_CSV_SETTINGS } from '../config';
|
|
26
26
|
import { DEFAULT_IS_VERBOSE } from '../config';
|
|
27
|
+
import { SET_IS_VERBOSE } from '../config';
|
|
27
28
|
import { DEFAULT_IS_AUTO_INSTALLED } from '../config';
|
|
28
29
|
import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
|
|
29
30
|
import { pipelineStringToJson } from '../conversion/pipelineStringToJson';
|
|
@@ -33,11 +34,12 @@ import { stringifyPipelineJson } from '../conversion/utils/stringifyPipelineJson
|
|
|
33
34
|
import { validatePipeline } from '../conversion/validation/validatePipeline';
|
|
34
35
|
import { CallbackInterfaceTools } from '../dialogs/callback/CallbackInterfaceTools';
|
|
35
36
|
import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
|
|
37
|
+
import { BoilerplateError } from '../errors/0-BoilerplateError';
|
|
38
|
+
import { ERRORS } from '../errors/0-index';
|
|
36
39
|
import { AbstractFormatError } from '../errors/AbstractFormatError';
|
|
37
40
|
import { CollectionError } from '../errors/CollectionError';
|
|
38
41
|
import { EnvironmentMismatchError } from '../errors/EnvironmentMismatchError';
|
|
39
42
|
import { ExpectError } from '../errors/ExpectError';
|
|
40
|
-
import { ERRORS } from '../errors/index';
|
|
41
43
|
import { KnowledgeScrapeError } from '../errors/KnowledgeScrapeError';
|
|
42
44
|
import { LimitReachedError } from '../errors/LimitReachedError';
|
|
43
45
|
import { MissingToolsError } from '../errors/MissingToolsError';
|
|
@@ -136,6 +138,7 @@ export { DEFAULT_REMOTE_URL };
|
|
|
136
138
|
export { DEFAULT_REMOTE_URL_PATH };
|
|
137
139
|
export { DEFAULT_CSV_SETTINGS };
|
|
138
140
|
export { DEFAULT_IS_VERBOSE };
|
|
141
|
+
export { SET_IS_VERBOSE };
|
|
139
142
|
export { DEFAULT_IS_AUTO_INSTALLED };
|
|
140
143
|
export { pipelineJsonToString };
|
|
141
144
|
export { pipelineStringToJson };
|
|
@@ -145,11 +148,12 @@ export { stringifyPipelineJson };
|
|
|
145
148
|
export { validatePipeline };
|
|
146
149
|
export { CallbackInterfaceTools };
|
|
147
150
|
export type { CallbackInterfaceToolsOptions };
|
|
151
|
+
export { BoilerplateError };
|
|
152
|
+
export { ERRORS };
|
|
148
153
|
export { AbstractFormatError };
|
|
149
154
|
export { CollectionError };
|
|
150
155
|
export { EnvironmentMismatchError };
|
|
151
156
|
export { ExpectError };
|
|
152
|
-
export { ERRORS };
|
|
153
157
|
export { KnowledgeScrapeError };
|
|
154
158
|
export { LimitReachedError };
|
|
155
159
|
export { MissingToolsError };
|
|
@@ -204,7 +204,15 @@ export declare const DEFAULT_CSV_SETTINGS: CsvSettings;
|
|
|
204
204
|
*
|
|
205
205
|
* @public exported from `@promptbook/core`
|
|
206
206
|
*/
|
|
207
|
-
export declare
|
|
207
|
+
export declare let DEFAULT_IS_VERBOSE: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* @@@
|
|
210
|
+
*
|
|
211
|
+
* Note: This is experimental feature
|
|
212
|
+
*
|
|
213
|
+
* @public exported from `@promptbook/core`
|
|
214
|
+
*/
|
|
215
|
+
export declare function SET_IS_VERBOSE(isVerbose: boolean): void;
|
|
208
216
|
/**
|
|
209
217
|
* @@@
|
|
210
218
|
*
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This error indicates @@@
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/core`
|
|
5
|
+
*/
|
|
6
|
+
export declare class BoilerplateError extends Error {
|
|
7
|
+
readonly name = "BoilerplateError";
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* TODO: @@@ Do not forget to add the error into `0-index.ts` ERRORS
|
|
12
|
+
*/
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { CsvFormatError } from '../formats/csv/CsvFormatError';
|
|
2
|
+
import { AbstractFormatError } from './AbstractFormatError';
|
|
1
3
|
import { CollectionError } from './CollectionError';
|
|
2
4
|
import { EnvironmentMismatchError } from './EnvironmentMismatchError';
|
|
3
5
|
import { ExpectError } from './ExpectError';
|
|
6
|
+
import { KnowledgeScrapeError } from './KnowledgeScrapeError';
|
|
4
7
|
import { LimitReachedError } from './LimitReachedError';
|
|
8
|
+
import { MissingToolsError } from './MissingToolsError';
|
|
5
9
|
import { NotFoundError } from './NotFoundError';
|
|
6
10
|
import { NotYetImplementedError } from './NotYetImplementedError';
|
|
7
11
|
import { ParseError } from './ParseError';
|
|
@@ -15,10 +19,14 @@ import { UnexpectedError } from './UnexpectedError';
|
|
|
15
19
|
* @public exported from `@promptbook/core`
|
|
16
20
|
*/
|
|
17
21
|
export declare const ERRORS: {
|
|
18
|
-
readonly
|
|
22
|
+
readonly AbstractFormatError: typeof AbstractFormatError;
|
|
23
|
+
readonly CsvFormatError: typeof CsvFormatError;
|
|
19
24
|
readonly CollectionError: typeof CollectionError;
|
|
20
25
|
readonly EnvironmentMismatchError: typeof EnvironmentMismatchError;
|
|
26
|
+
readonly ExpectError: typeof ExpectError;
|
|
27
|
+
readonly KnowledgeScrapeError: typeof KnowledgeScrapeError;
|
|
21
28
|
readonly LimitReachedError: typeof LimitReachedError;
|
|
29
|
+
readonly MissingToolsError: typeof MissingToolsError;
|
|
22
30
|
readonly NotFoundError: typeof NotFoundError;
|
|
23
31
|
readonly NotYetImplementedError: typeof NotYetImplementedError;
|
|
24
32
|
readonly ParseError: typeof ParseError;
|
|
@@ -29,4 +37,4 @@ export declare const ERRORS: {
|
|
|
29
37
|
};
|
|
30
38
|
/**
|
|
31
39
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
32
|
-
*/
|
|
40
|
+
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { string_markdown } from '../../../types/typeAliases';
|
|
2
|
+
import type { Scraper } from '../Scraper';
|
|
2
3
|
/**
|
|
3
4
|
* Creates a message with all registered scrapers
|
|
4
5
|
*
|
|
@@ -6,7 +7,7 @@ import type { string_markdown } from '../../../types/typeAliases';
|
|
|
6
7
|
*
|
|
7
8
|
* @private internal function of `createScrapersFromConfiguration` and `createScrapersFromEnv`
|
|
8
9
|
*/
|
|
9
|
-
export declare function $registeredScrapersMessage(): string_markdown;
|
|
10
|
+
export declare function $registeredScrapersMessage(availableScrapers: ReadonlyArray<Scraper>): string_markdown;
|
|
10
11
|
/**
|
|
11
12
|
* TODO: [®] DRY Register logic
|
|
12
13
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.75.
|
|
3
|
+
"version": "0.75.5",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"--note-0": " <- [🐊]",
|
|
6
6
|
"private": false,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"module": "./esm/index.es.js",
|
|
55
55
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@promptbook/core": "0.75.
|
|
57
|
+
"@promptbook/core": "0.75.5"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
*
|
|
44
44
|
* @see https://github.com/webgptorg/promptbook
|
|
45
45
|
*/
|
|
46
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.75.
|
|
46
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.4';
|
|
47
47
|
/**
|
|
48
48
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
49
49
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2026,6 +2026,42 @@
|
|
|
2026
2026
|
return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
2027
2027
|
}
|
|
2028
2028
|
|
|
2029
|
+
/**
|
|
2030
|
+
* This error indicates problems parsing the format value
|
|
2031
|
+
*
|
|
2032
|
+
* For example, when the format value is not a valid JSON or CSV
|
|
2033
|
+
* This is not thrown directly but in extended classes
|
|
2034
|
+
*
|
|
2035
|
+
* @public exported from `@promptbook/core`
|
|
2036
|
+
*/
|
|
2037
|
+
var AbstractFormatError = /** @class */ (function (_super) {
|
|
2038
|
+
__extends(AbstractFormatError, _super);
|
|
2039
|
+
// Note: To allow instanceof do not put here error `name`
|
|
2040
|
+
// public readonly name = 'AbstractFormatError';
|
|
2041
|
+
function AbstractFormatError(message) {
|
|
2042
|
+
var _this = _super.call(this, message) || this;
|
|
2043
|
+
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
2044
|
+
return _this;
|
|
2045
|
+
}
|
|
2046
|
+
return AbstractFormatError;
|
|
2047
|
+
}(Error));
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* This error indicates problem with parsing of CSV
|
|
2051
|
+
*
|
|
2052
|
+
* @public exported from `@promptbook/core`
|
|
2053
|
+
*/
|
|
2054
|
+
var CsvFormatError = /** @class */ (function (_super) {
|
|
2055
|
+
__extends(CsvFormatError, _super);
|
|
2056
|
+
function CsvFormatError(message) {
|
|
2057
|
+
var _this = _super.call(this, message) || this;
|
|
2058
|
+
_this.name = 'CsvFormatError';
|
|
2059
|
+
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
2060
|
+
return _this;
|
|
2061
|
+
}
|
|
2062
|
+
return CsvFormatError;
|
|
2063
|
+
}(AbstractFormatError));
|
|
2064
|
+
|
|
2029
2065
|
/**
|
|
2030
2066
|
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
2031
2067
|
*
|
|
@@ -2077,6 +2113,22 @@
|
|
|
2077
2113
|
return ExpectError;
|
|
2078
2114
|
}(Error));
|
|
2079
2115
|
|
|
2116
|
+
/**
|
|
2117
|
+
* This error indicates that the promptbook can not retrieve knowledge from external sources
|
|
2118
|
+
*
|
|
2119
|
+
* @public exported from `@promptbook/core`
|
|
2120
|
+
*/
|
|
2121
|
+
var KnowledgeScrapeError = /** @class */ (function (_super) {
|
|
2122
|
+
__extends(KnowledgeScrapeError, _super);
|
|
2123
|
+
function KnowledgeScrapeError(message) {
|
|
2124
|
+
var _this = _super.call(this, message) || this;
|
|
2125
|
+
_this.name = 'KnowledgeScrapeError';
|
|
2126
|
+
Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
|
|
2127
|
+
return _this;
|
|
2128
|
+
}
|
|
2129
|
+
return KnowledgeScrapeError;
|
|
2130
|
+
}(Error));
|
|
2131
|
+
|
|
2080
2132
|
/**
|
|
2081
2133
|
* This error type indicates that some limit was reached
|
|
2082
2134
|
*
|
|
@@ -2115,10 +2167,14 @@
|
|
|
2115
2167
|
* @public exported from `@promptbook/core`
|
|
2116
2168
|
*/
|
|
2117
2169
|
var ERRORS = {
|
|
2118
|
-
|
|
2170
|
+
AbstractFormatError: AbstractFormatError,
|
|
2171
|
+
CsvFormatError: CsvFormatError,
|
|
2119
2172
|
CollectionError: CollectionError,
|
|
2120
2173
|
EnvironmentMismatchError: EnvironmentMismatchError,
|
|
2174
|
+
ExpectError: ExpectError,
|
|
2175
|
+
KnowledgeScrapeError: KnowledgeScrapeError,
|
|
2121
2176
|
LimitReachedError: LimitReachedError,
|
|
2177
|
+
MissingToolsError: MissingToolsError,
|
|
2122
2178
|
NotFoundError: NotFoundError,
|
|
2123
2179
|
NotYetImplementedError: NotYetImplementedError,
|
|
2124
2180
|
ParseError: ParseError,
|
|
@@ -2431,42 +2487,6 @@
|
|
|
2431
2487
|
return union;
|
|
2432
2488
|
}
|
|
2433
2489
|
|
|
2434
|
-
/**
|
|
2435
|
-
* This error indicates problems parsing the format value
|
|
2436
|
-
*
|
|
2437
|
-
* For example, when the format value is not a valid JSON or CSV
|
|
2438
|
-
* This is not thrown directly but in extended classes
|
|
2439
|
-
*
|
|
2440
|
-
* @public exported from `@promptbook/core`
|
|
2441
|
-
*/
|
|
2442
|
-
var AbstractFormatError = /** @class */ (function (_super) {
|
|
2443
|
-
__extends(AbstractFormatError, _super);
|
|
2444
|
-
// Note: To allow instanceof do not put here error `name`
|
|
2445
|
-
// public readonly name = 'AbstractFormatError';
|
|
2446
|
-
function AbstractFormatError(message) {
|
|
2447
|
-
var _this = _super.call(this, message) || this;
|
|
2448
|
-
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
2449
|
-
return _this;
|
|
2450
|
-
}
|
|
2451
|
-
return AbstractFormatError;
|
|
2452
|
-
}(Error));
|
|
2453
|
-
|
|
2454
|
-
/**
|
|
2455
|
-
* This error indicates problem with parsing of CSV
|
|
2456
|
-
*
|
|
2457
|
-
* @public exported from `@promptbook/core`
|
|
2458
|
-
*/
|
|
2459
|
-
var CsvFormatError = /** @class */ (function (_super) {
|
|
2460
|
-
__extends(CsvFormatError, _super);
|
|
2461
|
-
function CsvFormatError(message) {
|
|
2462
|
-
var _this = _super.call(this, message) || this;
|
|
2463
|
-
_this.name = 'CsvFormatError';
|
|
2464
|
-
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
2465
|
-
return _this;
|
|
2466
|
-
}
|
|
2467
|
-
return CsvFormatError;
|
|
2468
|
-
}(AbstractFormatError));
|
|
2469
|
-
|
|
2470
2490
|
/**
|
|
2471
2491
|
* @@@
|
|
2472
2492
|
*
|
|
@@ -2507,7 +2527,7 @@
|
|
|
2507
2527
|
case 0:
|
|
2508
2528
|
csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2509
2529
|
if (csv.errors.length !== 0) {
|
|
2510
|
-
throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
|
|
2530
|
+
throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
|
|
2511
2531
|
}
|
|
2512
2532
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
2513
2533
|
var _a, _b;
|
|
@@ -2545,7 +2565,7 @@
|
|
|
2545
2565
|
case 0:
|
|
2546
2566
|
csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2547
2567
|
if (csv.errors.length !== 0) {
|
|
2548
|
-
throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
|
|
2568
|
+
throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
|
|
2549
2569
|
}
|
|
2550
2570
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, rowIndex) { return __awaiter(_this, void 0, void 0, function () {
|
|
2551
2571
|
var _this = this;
|
|
@@ -4583,22 +4603,6 @@
|
|
|
4583
4603
|
* TODO: [🏢] !! Check validity of `temperature` in pipeline
|
|
4584
4604
|
*/
|
|
4585
4605
|
|
|
4586
|
-
/**
|
|
4587
|
-
* This error indicates that the promptbook can not retrieve knowledge from external sources
|
|
4588
|
-
*
|
|
4589
|
-
* @public exported from `@promptbook/core`
|
|
4590
|
-
*/
|
|
4591
|
-
var KnowledgeScrapeError = /** @class */ (function (_super) {
|
|
4592
|
-
__extends(KnowledgeScrapeError, _super);
|
|
4593
|
-
function KnowledgeScrapeError(message) {
|
|
4594
|
-
var _this = _super.call(this, message) || this;
|
|
4595
|
-
_this.name = 'KnowledgeScrapeError';
|
|
4596
|
-
Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
|
|
4597
|
-
return _this;
|
|
4598
|
-
}
|
|
4599
|
-
return KnowledgeScrapeError;
|
|
4600
|
-
}(Error));
|
|
4601
|
-
|
|
4602
4606
|
/**
|
|
4603
4607
|
* @@@
|
|
4604
4608
|
*
|
|
@@ -4769,8 +4773,8 @@
|
|
|
4769
4773
|
*
|
|
4770
4774
|
* @private internal function of `createScrapersFromConfiguration` and `createScrapersFromEnv`
|
|
4771
4775
|
*/
|
|
4772
|
-
function $registeredScrapersMessage() {
|
|
4773
|
-
var e_1, _a, e_2, _b;
|
|
4776
|
+
function $registeredScrapersMessage(availableScrapers) {
|
|
4777
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
4774
4778
|
/**
|
|
4775
4779
|
* Mixes registered scrapers from $scrapersMetadataRegister and $scrapersRegister
|
|
4776
4780
|
*/
|
|
@@ -4782,15 +4786,15 @@
|
|
|
4782
4786
|
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
4783
4787
|
};
|
|
4784
4788
|
try {
|
|
4785
|
-
for (var
|
|
4786
|
-
var
|
|
4789
|
+
for (var _d = __values($scrapersMetadataRegister.list()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
4790
|
+
var _f = _e.value, packageName = _f.packageName, className = _f.className, mimeTypes = _f.mimeTypes, documentationUrl = _f.documentationUrl, isAvilableInBrowser = _f.isAvilableInBrowser;
|
|
4787
4791
|
_loop_1(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
4788
4792
|
}
|
|
4789
4793
|
}
|
|
4790
4794
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4791
4795
|
finally {
|
|
4792
4796
|
try {
|
|
4793
|
-
if (
|
|
4797
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
4794
4798
|
}
|
|
4795
4799
|
finally { if (e_1) throw e_1.error; }
|
|
4796
4800
|
}
|
|
@@ -4801,18 +4805,31 @@
|
|
|
4801
4805
|
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
4802
4806
|
};
|
|
4803
4807
|
try {
|
|
4804
|
-
for (var
|
|
4805
|
-
var
|
|
4808
|
+
for (var _g = __values($scrapersRegister.list()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
4809
|
+
var _j = _h.value, packageName = _j.packageName, className = _j.className, mimeTypes = _j.mimeTypes, documentationUrl = _j.documentationUrl, isAvilableInBrowser = _j.isAvilableInBrowser;
|
|
4806
4810
|
_loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
4807
4811
|
}
|
|
4808
4812
|
}
|
|
4809
4813
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
4810
4814
|
finally {
|
|
4811
4815
|
try {
|
|
4812
|
-
if (
|
|
4816
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
4813
4817
|
}
|
|
4814
4818
|
finally { if (e_2) throw e_2.error; }
|
|
4815
4819
|
}
|
|
4820
|
+
try {
|
|
4821
|
+
for (var availableScrapers_1 = __values(availableScrapers), availableScrapers_1_1 = availableScrapers_1.next(); !availableScrapers_1_1.done; availableScrapers_1_1 = availableScrapers_1.next()) {
|
|
4822
|
+
var metadata_1 = availableScrapers_1_1.value.metadata;
|
|
4823
|
+
all.push(metadata_1);
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
4827
|
+
finally {
|
|
4828
|
+
try {
|
|
4829
|
+
if (availableScrapers_1_1 && !availableScrapers_1_1.done && (_c = availableScrapers_1.return)) _c.call(availableScrapers_1);
|
|
4830
|
+
}
|
|
4831
|
+
finally { if (e_3) throw e_3.error; }
|
|
4832
|
+
}
|
|
4816
4833
|
var metadata = all.map(function (metadata) {
|
|
4817
4834
|
var isMetadataAviailable = $scrapersMetadataRegister
|
|
4818
4835
|
.list()
|
|
@@ -4826,42 +4843,44 @@
|
|
|
4826
4843
|
var packageName = _a.packageName, className = _a.className;
|
|
4827
4844
|
return metadata.packageName === packageName && metadata.className === className;
|
|
4828
4845
|
});
|
|
4829
|
-
|
|
4846
|
+
var isAvilableInTools = availableScrapers.some(function (_a) {
|
|
4847
|
+
var _b = _a.metadata, packageName = _b.packageName, className = _b.className;
|
|
4848
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
4849
|
+
});
|
|
4850
|
+
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
|
|
4830
4851
|
});
|
|
4831
4852
|
if (metadata.length === 0) {
|
|
4832
|
-
return "No scrapers are available";
|
|
4853
|
+
return spaceTrim__default["default"]("\n **No scrapers are available**\n\n This is a unexpected behavior, you are probably using some broken version of Promptbook\n At least there should be available the metadata of the scrapers\n ");
|
|
4833
4854
|
}
|
|
4834
4855
|
return spaceTrim__default["default"](function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
|
|
4835
4856
|
.map(function (_a, i) {
|
|
4836
|
-
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser;
|
|
4837
|
-
var more;
|
|
4838
|
-
// TODO:
|
|
4839
|
-
if (
|
|
4840
|
-
more
|
|
4841
|
-
}
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
more = "(installed)";
|
|
4855
|
-
}
|
|
4856
|
-
else {
|
|
4857
|
-
more = "*(unknown state, looks like a unexpected behavior)*";
|
|
4858
|
-
}
|
|
4857
|
+
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
|
|
4858
|
+
var more = [];
|
|
4859
|
+
// TODO: [🧠] Maybe use `documentationUrl`
|
|
4860
|
+
if (isMetadataAviailable) {
|
|
4861
|
+
more.push("\u2B1C Metadata registered");
|
|
4862
|
+
} // not else
|
|
4863
|
+
if (isInstalled) {
|
|
4864
|
+
more.push("\uD83D\uDFE9 Installed");
|
|
4865
|
+
} // not else
|
|
4866
|
+
if (isAvilableInTools) {
|
|
4867
|
+
more.push("\uD83D\uDFE6 Available in tools");
|
|
4868
|
+
} // not else
|
|
4869
|
+
if (!isMetadataAviailable && isInstalled) {
|
|
4870
|
+
more.push("When no metadata registered but scraper is installed, it is an unexpected behavior");
|
|
4871
|
+
} // not else
|
|
4872
|
+
if (!isInstalled && isAvilableInTools) {
|
|
4873
|
+
more.push("When the scraper is not installed but available in tools, it is an unexpected compatibility behavior");
|
|
4874
|
+
} // not else
|
|
4859
4875
|
if (!isAvilableInBrowser) {
|
|
4860
|
-
more
|
|
4876
|
+
more.push("Not usable in browser");
|
|
4861
4877
|
}
|
|
4862
|
-
|
|
4878
|
+
var moreText = more.length === 0 ? '' : " *(".concat(more.join('; '), ")*");
|
|
4879
|
+
return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes
|
|
4880
|
+
.map(function (mimeType) { return "\"".concat(mimeType, "\""); })
|
|
4881
|
+
.join(', ')).concat(moreText);
|
|
4863
4882
|
})
|
|
4864
|
-
.join('\n')), "\n "); });
|
|
4883
|
+
.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 "); });
|
|
4865
4884
|
}
|
|
4866
4885
|
/**
|
|
4867
4886
|
* TODO: [®] DRY Register logic
|
|
@@ -5197,57 +5216,75 @@
|
|
|
5197
5216
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
|
|
5198
5217
|
knowledgePreparedUnflatten = new Array(knowledgeSources.length);
|
|
5199
5218
|
return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
5200
|
-
var partialPieces, sourceHandler,
|
|
5201
|
-
var e_1,
|
|
5202
|
-
return __generator(this, function (
|
|
5203
|
-
switch (
|
|
5219
|
+
var partialPieces, sourceHandler, scrapers, _loop_1, scrapers_1, scrapers_1_1, scraper, state_1, e_1_1, pieces;
|
|
5220
|
+
var e_1, _a;
|
|
5221
|
+
return __generator(this, function (_b) {
|
|
5222
|
+
switch (_b.label) {
|
|
5204
5223
|
case 0:
|
|
5205
5224
|
partialPieces = null;
|
|
5206
5225
|
return [4 /*yield*/, makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname: rootDirname, isVerbose: isVerbose })];
|
|
5207
5226
|
case 1:
|
|
5208
|
-
sourceHandler =
|
|
5209
|
-
|
|
5227
|
+
sourceHandler = _b.sent();
|
|
5228
|
+
scrapers = arrayableToArray(tools.scrapers);
|
|
5229
|
+
_loop_1 = function (scraper) {
|
|
5230
|
+
var partialPiecesUnchecked;
|
|
5231
|
+
return __generator(this, function (_c) {
|
|
5232
|
+
switch (_c.label) {
|
|
5233
|
+
case 0:
|
|
5234
|
+
if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
|
|
5235
|
+
// <- TODO: [🦔] Implement mime-type wildcards
|
|
5236
|
+
) {
|
|
5237
|
+
return [2 /*return*/, "continue"];
|
|
5238
|
+
}
|
|
5239
|
+
return [4 /*yield*/, scraper.scrape(sourceHandler)];
|
|
5240
|
+
case 1:
|
|
5241
|
+
partialPiecesUnchecked = _c.sent();
|
|
5242
|
+
if (partialPiecesUnchecked !== null) {
|
|
5243
|
+
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
5244
|
+
return [2 /*return*/, "break"];
|
|
5245
|
+
}
|
|
5246
|
+
console.warn(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n \n The source:\n > ").concat(block(knowledgeSource.sourceContent
|
|
5247
|
+
.split('\n')
|
|
5248
|
+
.map(function (line) { return "> ".concat(line); })
|
|
5249
|
+
.join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
5250
|
+
return [2 /*return*/];
|
|
5251
|
+
}
|
|
5252
|
+
});
|
|
5253
|
+
};
|
|
5254
|
+
_b.label = 2;
|
|
5210
5255
|
case 2:
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5256
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
5257
|
+
scrapers_1 = __values(scrapers), scrapers_1_1 = scrapers_1.next();
|
|
5258
|
+
_b.label = 3;
|
|
5214
5259
|
case 3:
|
|
5215
|
-
if (!!
|
|
5216
|
-
scraper =
|
|
5217
|
-
|
|
5218
|
-
// <- TODO: [🦔] Implement mime-type wildcards
|
|
5219
|
-
) {
|
|
5220
|
-
return [3 /*break*/, 5];
|
|
5221
|
-
}
|
|
5222
|
-
return [4 /*yield*/, scraper.scrape(sourceHandler)];
|
|
5260
|
+
if (!!scrapers_1_1.done) return [3 /*break*/, 6];
|
|
5261
|
+
scraper = scrapers_1_1.value;
|
|
5262
|
+
return [5 /*yield**/, _loop_1(scraper)];
|
|
5223
5263
|
case 4:
|
|
5224
|
-
|
|
5225
|
-
if (
|
|
5226
|
-
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
5227
|
-
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
5264
|
+
state_1 = _b.sent();
|
|
5265
|
+
if (state_1 === "break")
|
|
5228
5266
|
return [3 /*break*/, 6];
|
|
5229
|
-
|
|
5230
|
-
_d.label = 5;
|
|
5267
|
+
_b.label = 5;
|
|
5231
5268
|
case 5:
|
|
5232
|
-
|
|
5269
|
+
scrapers_1_1 = scrapers_1.next();
|
|
5233
5270
|
return [3 /*break*/, 3];
|
|
5234
5271
|
case 6: return [3 /*break*/, 9];
|
|
5235
5272
|
case 7:
|
|
5236
|
-
e_1_1 =
|
|
5273
|
+
e_1_1 = _b.sent();
|
|
5237
5274
|
e_1 = { error: e_1_1 };
|
|
5238
5275
|
return [3 /*break*/, 9];
|
|
5239
5276
|
case 8:
|
|
5240
5277
|
try {
|
|
5241
|
-
if (
|
|
5278
|
+
if (scrapers_1_1 && !scrapers_1_1.done && (_a = scrapers_1.return)) _a.call(scrapers_1);
|
|
5242
5279
|
}
|
|
5243
5280
|
finally { if (e_1) throw e_1.error; }
|
|
5244
5281
|
return [7 /*endfinally*/];
|
|
5245
5282
|
case 9:
|
|
5246
5283
|
if (partialPieces === null) {
|
|
5247
|
-
throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge
|
|
5284
|
+
throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n \n The source:\n > ".concat(block(knowledgeSource.sourceContent
|
|
5248
5285
|
.split('\n')
|
|
5249
5286
|
.map(function (line) { return "> ".concat(line); })
|
|
5250
|
-
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage()), "\n\n\n "); }));
|
|
5287
|
+
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
5251
5288
|
}
|
|
5252
5289
|
pieces = partialPieces.map(function (partialPiece) { return (__assign(__assign({}, partialPiece), { sources: [
|
|
5253
5290
|
{
|