@promptbook/cli 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 +1 -1
- 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
package/umd/index.umd.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
*
|
|
50
50
|
* @see https://github.com/webgptorg/promptbook
|
|
51
51
|
*/
|
|
52
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.75.
|
|
52
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.4';
|
|
53
53
|
/**
|
|
54
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
55
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2227,6 +2227,42 @@
|
|
|
2227
2227
|
return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
2228
2228
|
}
|
|
2229
2229
|
|
|
2230
|
+
/**
|
|
2231
|
+
* This error indicates problems parsing the format value
|
|
2232
|
+
*
|
|
2233
|
+
* For example, when the format value is not a valid JSON or CSV
|
|
2234
|
+
* This is not thrown directly but in extended classes
|
|
2235
|
+
*
|
|
2236
|
+
* @public exported from `@promptbook/core`
|
|
2237
|
+
*/
|
|
2238
|
+
var AbstractFormatError = /** @class */ (function (_super) {
|
|
2239
|
+
__extends(AbstractFormatError, _super);
|
|
2240
|
+
// Note: To allow instanceof do not put here error `name`
|
|
2241
|
+
// public readonly name = 'AbstractFormatError';
|
|
2242
|
+
function AbstractFormatError(message) {
|
|
2243
|
+
var _this = _super.call(this, message) || this;
|
|
2244
|
+
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
2245
|
+
return _this;
|
|
2246
|
+
}
|
|
2247
|
+
return AbstractFormatError;
|
|
2248
|
+
}(Error));
|
|
2249
|
+
|
|
2250
|
+
/**
|
|
2251
|
+
* This error indicates problem with parsing of CSV
|
|
2252
|
+
*
|
|
2253
|
+
* @public exported from `@promptbook/core`
|
|
2254
|
+
*/
|
|
2255
|
+
var CsvFormatError = /** @class */ (function (_super) {
|
|
2256
|
+
__extends(CsvFormatError, _super);
|
|
2257
|
+
function CsvFormatError(message) {
|
|
2258
|
+
var _this = _super.call(this, message) || this;
|
|
2259
|
+
_this.name = 'CsvFormatError';
|
|
2260
|
+
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
2261
|
+
return _this;
|
|
2262
|
+
}
|
|
2263
|
+
return CsvFormatError;
|
|
2264
|
+
}(AbstractFormatError));
|
|
2265
|
+
|
|
2230
2266
|
/**
|
|
2231
2267
|
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
2232
2268
|
*
|
|
@@ -2262,6 +2298,22 @@
|
|
|
2262
2298
|
return ExpectError;
|
|
2263
2299
|
}(Error));
|
|
2264
2300
|
|
|
2301
|
+
/**
|
|
2302
|
+
* This error indicates that the promptbook can not retrieve knowledge from external sources
|
|
2303
|
+
*
|
|
2304
|
+
* @public exported from `@promptbook/core`
|
|
2305
|
+
*/
|
|
2306
|
+
var KnowledgeScrapeError = /** @class */ (function (_super) {
|
|
2307
|
+
__extends(KnowledgeScrapeError, _super);
|
|
2308
|
+
function KnowledgeScrapeError(message) {
|
|
2309
|
+
var _this = _super.call(this, message) || this;
|
|
2310
|
+
_this.name = 'KnowledgeScrapeError';
|
|
2311
|
+
Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
|
|
2312
|
+
return _this;
|
|
2313
|
+
}
|
|
2314
|
+
return KnowledgeScrapeError;
|
|
2315
|
+
}(Error));
|
|
2316
|
+
|
|
2265
2317
|
/**
|
|
2266
2318
|
* This error type indicates that some limit was reached
|
|
2267
2319
|
*
|
|
@@ -2300,10 +2352,14 @@
|
|
|
2300
2352
|
* @public exported from `@promptbook/core`
|
|
2301
2353
|
*/
|
|
2302
2354
|
var ERRORS = {
|
|
2303
|
-
|
|
2355
|
+
AbstractFormatError: AbstractFormatError,
|
|
2356
|
+
CsvFormatError: CsvFormatError,
|
|
2304
2357
|
CollectionError: CollectionError,
|
|
2305
2358
|
EnvironmentMismatchError: EnvironmentMismatchError,
|
|
2359
|
+
ExpectError: ExpectError,
|
|
2360
|
+
KnowledgeScrapeError: KnowledgeScrapeError,
|
|
2306
2361
|
LimitReachedError: LimitReachedError,
|
|
2362
|
+
MissingToolsError: MissingToolsError,
|
|
2307
2363
|
NotFoundError: NotFoundError,
|
|
2308
2364
|
NotYetImplementedError: NotYetImplementedError,
|
|
2309
2365
|
ParseError: ParseError,
|
|
@@ -2629,42 +2685,6 @@
|
|
|
2629
2685
|
function TODO_USE() {
|
|
2630
2686
|
}
|
|
2631
2687
|
|
|
2632
|
-
/**
|
|
2633
|
-
* This error indicates problems parsing the format value
|
|
2634
|
-
*
|
|
2635
|
-
* For example, when the format value is not a valid JSON or CSV
|
|
2636
|
-
* This is not thrown directly but in extended classes
|
|
2637
|
-
*
|
|
2638
|
-
* @public exported from `@promptbook/core`
|
|
2639
|
-
*/
|
|
2640
|
-
var AbstractFormatError = /** @class */ (function (_super) {
|
|
2641
|
-
__extends(AbstractFormatError, _super);
|
|
2642
|
-
// Note: To allow instanceof do not put here error `name`
|
|
2643
|
-
// public readonly name = 'AbstractFormatError';
|
|
2644
|
-
function AbstractFormatError(message) {
|
|
2645
|
-
var _this = _super.call(this, message) || this;
|
|
2646
|
-
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
2647
|
-
return _this;
|
|
2648
|
-
}
|
|
2649
|
-
return AbstractFormatError;
|
|
2650
|
-
}(Error));
|
|
2651
|
-
|
|
2652
|
-
/**
|
|
2653
|
-
* This error indicates problem with parsing of CSV
|
|
2654
|
-
*
|
|
2655
|
-
* @public exported from `@promptbook/core`
|
|
2656
|
-
*/
|
|
2657
|
-
var CsvFormatError = /** @class */ (function (_super) {
|
|
2658
|
-
__extends(CsvFormatError, _super);
|
|
2659
|
-
function CsvFormatError(message) {
|
|
2660
|
-
var _this = _super.call(this, message) || this;
|
|
2661
|
-
_this.name = 'CsvFormatError';
|
|
2662
|
-
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
2663
|
-
return _this;
|
|
2664
|
-
}
|
|
2665
|
-
return CsvFormatError;
|
|
2666
|
-
}(AbstractFormatError));
|
|
2667
|
-
|
|
2668
2688
|
/**
|
|
2669
2689
|
* @@@
|
|
2670
2690
|
*
|
|
@@ -2705,7 +2725,7 @@
|
|
|
2705
2725
|
case 0:
|
|
2706
2726
|
csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2707
2727
|
if (csv.errors.length !== 0) {
|
|
2708
|
-
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 "); }));
|
|
2728
|
+
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 "); }));
|
|
2709
2729
|
}
|
|
2710
2730
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
2711
2731
|
var _a, _b;
|
|
@@ -2743,7 +2763,7 @@
|
|
|
2743
2763
|
case 0:
|
|
2744
2764
|
csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2745
2765
|
if (csv.errors.length !== 0) {
|
|
2746
|
-
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 "); }));
|
|
2766
|
+
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 "); }));
|
|
2747
2767
|
}
|
|
2748
2768
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, rowIndex) { return __awaiter(_this, void 0, void 0, function () {
|
|
2749
2769
|
var _this = this;
|
|
@@ -4781,22 +4801,6 @@
|
|
|
4781
4801
|
* TODO: [🏢] !! Check validity of `temperature` in pipeline
|
|
4782
4802
|
*/
|
|
4783
4803
|
|
|
4784
|
-
/**
|
|
4785
|
-
* This error indicates that the promptbook can not retrieve knowledge from external sources
|
|
4786
|
-
*
|
|
4787
|
-
* @public exported from `@promptbook/core`
|
|
4788
|
-
*/
|
|
4789
|
-
var KnowledgeScrapeError = /** @class */ (function (_super) {
|
|
4790
|
-
__extends(KnowledgeScrapeError, _super);
|
|
4791
|
-
function KnowledgeScrapeError(message) {
|
|
4792
|
-
var _this = _super.call(this, message) || this;
|
|
4793
|
-
_this.name = 'KnowledgeScrapeError';
|
|
4794
|
-
Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
|
|
4795
|
-
return _this;
|
|
4796
|
-
}
|
|
4797
|
-
return KnowledgeScrapeError;
|
|
4798
|
-
}(Error));
|
|
4799
|
-
|
|
4800
4804
|
/**
|
|
4801
4805
|
* @@@
|
|
4802
4806
|
*
|
|
@@ -4967,8 +4971,8 @@
|
|
|
4967
4971
|
*
|
|
4968
4972
|
* @private internal function of `createScrapersFromConfiguration` and `createScrapersFromEnv`
|
|
4969
4973
|
*/
|
|
4970
|
-
function $registeredScrapersMessage() {
|
|
4971
|
-
var e_1, _a, e_2, _b;
|
|
4974
|
+
function $registeredScrapersMessage(availableScrapers) {
|
|
4975
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
4972
4976
|
/**
|
|
4973
4977
|
* Mixes registered scrapers from $scrapersMetadataRegister and $scrapersRegister
|
|
4974
4978
|
*/
|
|
@@ -4980,15 +4984,15 @@
|
|
|
4980
4984
|
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
4981
4985
|
};
|
|
4982
4986
|
try {
|
|
4983
|
-
for (var
|
|
4984
|
-
var
|
|
4987
|
+
for (var _d = __values($scrapersMetadataRegister.list()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
4988
|
+
var _f = _e.value, packageName = _f.packageName, className = _f.className, mimeTypes = _f.mimeTypes, documentationUrl = _f.documentationUrl, isAvilableInBrowser = _f.isAvilableInBrowser;
|
|
4985
4989
|
_loop_1(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
4986
4990
|
}
|
|
4987
4991
|
}
|
|
4988
4992
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4989
4993
|
finally {
|
|
4990
4994
|
try {
|
|
4991
|
-
if (
|
|
4995
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
4992
4996
|
}
|
|
4993
4997
|
finally { if (e_1) throw e_1.error; }
|
|
4994
4998
|
}
|
|
@@ -4999,18 +5003,31 @@
|
|
|
4999
5003
|
all.push({ packageName: packageName, className: className, mimeTypes: mimeTypes, documentationUrl: documentationUrl, isAvilableInBrowser: isAvilableInBrowser });
|
|
5000
5004
|
};
|
|
5001
5005
|
try {
|
|
5002
|
-
for (var
|
|
5003
|
-
var
|
|
5006
|
+
for (var _g = __values($scrapersRegister.list()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
5007
|
+
var _j = _h.value, packageName = _j.packageName, className = _j.className, mimeTypes = _j.mimeTypes, documentationUrl = _j.documentationUrl, isAvilableInBrowser = _j.isAvilableInBrowser;
|
|
5004
5008
|
_loop_2(packageName, className, mimeTypes, documentationUrl, isAvilableInBrowser);
|
|
5005
5009
|
}
|
|
5006
5010
|
}
|
|
5007
5011
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
5008
5012
|
finally {
|
|
5009
5013
|
try {
|
|
5010
|
-
if (
|
|
5014
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
5011
5015
|
}
|
|
5012
5016
|
finally { if (e_2) throw e_2.error; }
|
|
5013
5017
|
}
|
|
5018
|
+
try {
|
|
5019
|
+
for (var availableScrapers_1 = __values(availableScrapers), availableScrapers_1_1 = availableScrapers_1.next(); !availableScrapers_1_1.done; availableScrapers_1_1 = availableScrapers_1.next()) {
|
|
5020
|
+
var metadata_1 = availableScrapers_1_1.value.metadata;
|
|
5021
|
+
all.push(metadata_1);
|
|
5022
|
+
}
|
|
5023
|
+
}
|
|
5024
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
5025
|
+
finally {
|
|
5026
|
+
try {
|
|
5027
|
+
if (availableScrapers_1_1 && !availableScrapers_1_1.done && (_c = availableScrapers_1.return)) _c.call(availableScrapers_1);
|
|
5028
|
+
}
|
|
5029
|
+
finally { if (e_3) throw e_3.error; }
|
|
5030
|
+
}
|
|
5014
5031
|
var metadata = all.map(function (metadata) {
|
|
5015
5032
|
var isMetadataAviailable = $scrapersMetadataRegister
|
|
5016
5033
|
.list()
|
|
@@ -5024,42 +5041,44 @@
|
|
|
5024
5041
|
var packageName = _a.packageName, className = _a.className;
|
|
5025
5042
|
return metadata.packageName === packageName && metadata.className === className;
|
|
5026
5043
|
});
|
|
5027
|
-
|
|
5044
|
+
var isAvilableInTools = availableScrapers.some(function (_a) {
|
|
5045
|
+
var _b = _a.metadata, packageName = _b.packageName, className = _b.className;
|
|
5046
|
+
return metadata.packageName === packageName && metadata.className === className;
|
|
5047
|
+
});
|
|
5048
|
+
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isAvilableInTools: isAvilableInTools });
|
|
5028
5049
|
});
|
|
5029
5050
|
if (metadata.length === 0) {
|
|
5030
|
-
return "No scrapers are available";
|
|
5051
|
+
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 ");
|
|
5031
5052
|
}
|
|
5032
5053
|
return spaceTrim__default["default"](function (block) { return "\n Available scrapers are:\n ".concat(block(metadata
|
|
5033
5054
|
.map(function (_a, i) {
|
|
5034
|
-
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser;
|
|
5035
|
-
var more;
|
|
5036
|
-
// TODO:
|
|
5037
|
-
if (
|
|
5038
|
-
more
|
|
5039
|
-
}
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
more = "(installed)";
|
|
5053
|
-
}
|
|
5054
|
-
else {
|
|
5055
|
-
more = "*(unknown state, looks like a unexpected behavior)*";
|
|
5056
|
-
}
|
|
5055
|
+
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, mimeTypes = _a.mimeTypes, isAvilableInBrowser = _a.isAvilableInBrowser, isAvilableInTools = _a.isAvilableInTools;
|
|
5056
|
+
var more = [];
|
|
5057
|
+
// TODO: [🧠] Maybe use `documentationUrl`
|
|
5058
|
+
if (isMetadataAviailable) {
|
|
5059
|
+
more.push("\u2B1C Metadata registered");
|
|
5060
|
+
} // not else
|
|
5061
|
+
if (isInstalled) {
|
|
5062
|
+
more.push("\uD83D\uDFE9 Installed");
|
|
5063
|
+
} // not else
|
|
5064
|
+
if (isAvilableInTools) {
|
|
5065
|
+
more.push("\uD83D\uDFE6 Available in tools");
|
|
5066
|
+
} // not else
|
|
5067
|
+
if (!isMetadataAviailable && isInstalled) {
|
|
5068
|
+
more.push("When no metadata registered but scraper is installed, it is an unexpected behavior");
|
|
5069
|
+
} // not else
|
|
5070
|
+
if (!isInstalled && isAvilableInTools) {
|
|
5071
|
+
more.push("When the scraper is not installed but available in tools, it is an unexpected compatibility behavior");
|
|
5072
|
+
} // not else
|
|
5057
5073
|
if (!isAvilableInBrowser) {
|
|
5058
|
-
more
|
|
5074
|
+
more.push("Not usable in browser");
|
|
5059
5075
|
}
|
|
5060
|
-
|
|
5076
|
+
var moreText = more.length === 0 ? '' : " *(".concat(more.join('; '), ")*");
|
|
5077
|
+
return "".concat(i + 1, ") `").concat(className, "` from `").concat(packageName, "` compatible to scrape ").concat(mimeTypes
|
|
5078
|
+
.map(function (mimeType) { return "\"".concat(mimeType, "\""); })
|
|
5079
|
+
.join(', ')).concat(moreText);
|
|
5061
5080
|
})
|
|
5062
|
-
.join('\n')), "\n "); });
|
|
5081
|
+
.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 "); });
|
|
5063
5082
|
}
|
|
5064
5083
|
/**
|
|
5065
5084
|
* TODO: [®] DRY Register logic
|
|
@@ -5395,57 +5414,75 @@
|
|
|
5395
5414
|
_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;
|
|
5396
5415
|
knowledgePreparedUnflatten = new Array(knowledgeSources.length);
|
|
5397
5416
|
return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
5398
|
-
var partialPieces, sourceHandler,
|
|
5399
|
-
var e_1,
|
|
5400
|
-
return __generator(this, function (
|
|
5401
|
-
switch (
|
|
5417
|
+
var partialPieces, sourceHandler, scrapers, _loop_1, scrapers_1, scrapers_1_1, scraper, state_1, e_1_1, pieces;
|
|
5418
|
+
var e_1, _a;
|
|
5419
|
+
return __generator(this, function (_b) {
|
|
5420
|
+
switch (_b.label) {
|
|
5402
5421
|
case 0:
|
|
5403
5422
|
partialPieces = null;
|
|
5404
5423
|
return [4 /*yield*/, makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname: rootDirname, isVerbose: isVerbose })];
|
|
5405
5424
|
case 1:
|
|
5406
|
-
sourceHandler =
|
|
5407
|
-
|
|
5425
|
+
sourceHandler = _b.sent();
|
|
5426
|
+
scrapers = arrayableToArray(tools.scrapers);
|
|
5427
|
+
_loop_1 = function (scraper) {
|
|
5428
|
+
var partialPiecesUnchecked;
|
|
5429
|
+
return __generator(this, function (_c) {
|
|
5430
|
+
switch (_c.label) {
|
|
5431
|
+
case 0:
|
|
5432
|
+
if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
|
|
5433
|
+
// <- TODO: [🦔] Implement mime-type wildcards
|
|
5434
|
+
) {
|
|
5435
|
+
return [2 /*return*/, "continue"];
|
|
5436
|
+
}
|
|
5437
|
+
return [4 /*yield*/, scraper.scrape(sourceHandler)];
|
|
5438
|
+
case 1:
|
|
5439
|
+
partialPiecesUnchecked = _c.sent();
|
|
5440
|
+
if (partialPiecesUnchecked !== null) {
|
|
5441
|
+
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
5442
|
+
return [2 /*return*/, "break"];
|
|
5443
|
+
}
|
|
5444
|
+
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
|
|
5445
|
+
.split('\n')
|
|
5446
|
+
.map(function (line) { return "> ".concat(line); })
|
|
5447
|
+
.join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
5448
|
+
return [2 /*return*/];
|
|
5449
|
+
}
|
|
5450
|
+
});
|
|
5451
|
+
};
|
|
5452
|
+
_b.label = 2;
|
|
5408
5453
|
case 2:
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5454
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
5455
|
+
scrapers_1 = __values(scrapers), scrapers_1_1 = scrapers_1.next();
|
|
5456
|
+
_b.label = 3;
|
|
5412
5457
|
case 3:
|
|
5413
|
-
if (!!
|
|
5414
|
-
scraper =
|
|
5415
|
-
|
|
5416
|
-
// <- TODO: [🦔] Implement mime-type wildcards
|
|
5417
|
-
) {
|
|
5418
|
-
return [3 /*break*/, 5];
|
|
5419
|
-
}
|
|
5420
|
-
return [4 /*yield*/, scraper.scrape(sourceHandler)];
|
|
5458
|
+
if (!!scrapers_1_1.done) return [3 /*break*/, 6];
|
|
5459
|
+
scraper = scrapers_1_1.value;
|
|
5460
|
+
return [5 /*yield**/, _loop_1(scraper)];
|
|
5421
5461
|
case 4:
|
|
5422
|
-
|
|
5423
|
-
if (
|
|
5424
|
-
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
5425
|
-
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
5462
|
+
state_1 = _b.sent();
|
|
5463
|
+
if (state_1 === "break")
|
|
5426
5464
|
return [3 /*break*/, 6];
|
|
5427
|
-
|
|
5428
|
-
_d.label = 5;
|
|
5465
|
+
_b.label = 5;
|
|
5429
5466
|
case 5:
|
|
5430
|
-
|
|
5467
|
+
scrapers_1_1 = scrapers_1.next();
|
|
5431
5468
|
return [3 /*break*/, 3];
|
|
5432
5469
|
case 6: return [3 /*break*/, 9];
|
|
5433
5470
|
case 7:
|
|
5434
|
-
e_1_1 =
|
|
5471
|
+
e_1_1 = _b.sent();
|
|
5435
5472
|
e_1 = { error: e_1_1 };
|
|
5436
5473
|
return [3 /*break*/, 9];
|
|
5437
5474
|
case 8:
|
|
5438
5475
|
try {
|
|
5439
|
-
if (
|
|
5476
|
+
if (scrapers_1_1 && !scrapers_1_1.done && (_a = scrapers_1.return)) _a.call(scrapers_1);
|
|
5440
5477
|
}
|
|
5441
5478
|
finally { if (e_1) throw e_1.error; }
|
|
5442
5479
|
return [7 /*endfinally*/];
|
|
5443
5480
|
case 9:
|
|
5444
5481
|
if (partialPieces === null) {
|
|
5445
|
-
throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge
|
|
5482
|
+
throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n \n The source:\n > ".concat(block(knowledgeSource.sourceContent
|
|
5446
5483
|
.split('\n')
|
|
5447
5484
|
.map(function (line) { return "> ".concat(line); })
|
|
5448
|
-
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage()), "\n\n\n "); }));
|
|
5485
|
+
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
5449
5486
|
}
|
|
5450
5487
|
pieces = partialPieces.map(function (partialPiece) { return (__assign(__assign({}, partialPiece), { sources: [
|
|
5451
5488
|
{
|