@promptbook/website-crawler 0.71.0-21 → 0.71.0-23
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 +42 -41
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -4
- package/package.json +2 -2
- package/umd/index.umd.js +42 -41
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Converter } from 'showdown';
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook library
|
|
18
18
|
*/
|
|
19
|
-
var PROMPTBOOK_VERSION = '0.71.0-
|
|
19
|
+
var PROMPTBOOK_VERSION = '0.71.0-22';
|
|
20
20
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
21
21
|
|
|
22
22
|
/*! *****************************************************************************
|
|
@@ -3107,7 +3107,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3107
3107
|
return __awaiter(this, void 0, void 0, function () {
|
|
3108
3108
|
var sourceContent, name, _b, _c, rootDirname, _d,
|
|
3109
3109
|
// <- TODO: process.cwd() if running in Node.js
|
|
3110
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension,
|
|
3110
|
+
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3111
3111
|
return __generator(this, function (_e) {
|
|
3112
3112
|
switch (_e.label) {
|
|
3113
3113
|
case 0:
|
|
@@ -3129,19 +3129,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3129
3129
|
filename: null,
|
|
3130
3130
|
url: url,
|
|
3131
3131
|
mimeType: mimeType,
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
return [2 /*return*/, content];
|
|
3141
|
-
}
|
|
3142
|
-
});
|
|
3143
|
-
});
|
|
3144
|
-
},
|
|
3132
|
+
/*
|
|
3133
|
+
TODO: [🥽]
|
|
3134
|
+
> async asBlob() {
|
|
3135
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
3136
|
+
> const content = await response.blob();
|
|
3137
|
+
> return content;
|
|
3138
|
+
> },
|
|
3139
|
+
*/
|
|
3145
3140
|
asJson: function () {
|
|
3146
3141
|
return __awaiter(this, void 0, void 0, function () {
|
|
3147
3142
|
var content;
|
|
@@ -3181,34 +3176,31 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3181
3176
|
}
|
|
3182
3177
|
filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
|
|
3183
3178
|
fileExtension = getFileExtension(filename_1);
|
|
3184
|
-
|
|
3179
|
+
mimeType = extensionToMimeType(fileExtension || '');
|
|
3185
3180
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3186
3181
|
case 3:
|
|
3187
3182
|
if (!(_e.sent())) {
|
|
3188
3183
|
throw new NotFoundError(spaceTrim$1(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
3189
3184
|
}
|
|
3190
|
-
// TODO:
|
|
3185
|
+
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3191
3186
|
return [2 /*return*/, {
|
|
3192
3187
|
source: name,
|
|
3193
3188
|
filename: filename_1,
|
|
3194
3189
|
url: null,
|
|
3195
|
-
mimeType:
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
});
|
|
3210
|
-
});
|
|
3211
|
-
},
|
|
3190
|
+
mimeType: mimeType,
|
|
3191
|
+
/*
|
|
3192
|
+
TODO: [🥽]
|
|
3193
|
+
> async asBlob() {
|
|
3194
|
+
> const content = await tools.fs!.readFile(filename);
|
|
3195
|
+
> return new Blob(
|
|
3196
|
+
> [
|
|
3197
|
+
> content,
|
|
3198
|
+
> // <- TODO: [🥽] This is NOT tested, test it
|
|
3199
|
+
> ],
|
|
3200
|
+
> { type: mimeType },
|
|
3201
|
+
> );
|
|
3202
|
+
> },
|
|
3203
|
+
*/
|
|
3212
3204
|
asJson: function () {
|
|
3213
3205
|
return __awaiter(this, void 0, void 0, function () {
|
|
3214
3206
|
var _a, _b;
|
|
@@ -3244,9 +3236,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3244
3236
|
asJson: function () {
|
|
3245
3237
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
3246
3238
|
},
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3239
|
+
/*
|
|
3240
|
+
TODO: [🥽]
|
|
3241
|
+
> asBlob() {
|
|
3242
|
+
> throw new UnexpectedError(
|
|
3243
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
3244
|
+
> );
|
|
3245
|
+
> },
|
|
3246
|
+
*/
|
|
3250
3247
|
}];
|
|
3251
3248
|
}
|
|
3252
3249
|
});
|
|
@@ -5827,7 +5824,6 @@ var WebsiteScraper = /** @class */ (function () {
|
|
|
5827
5824
|
switch (_g.label) {
|
|
5828
5825
|
case 0:
|
|
5829
5826
|
_a = this.options, _b = _a.rootDirname, rootDirname = _b === void 0 ? process.cwd() : _b, _c = _a.cacheDirname, cacheDirname = _c === void 0 ? DEFAULT_SCRAPE_CACHE_DIRNAME : _c, _d = _a.intermediateFilesStrategy, intermediateFilesStrategy = _d === void 0 ? DEFAULT_INTERMEDIATE_FILES_STRATEGY : _d, _e = _a.isVerbose, isVerbose = _e === void 0 ? DEFAULT_IS_VERBOSE : _e;
|
|
5830
|
-
// TODO: !!!!!! Does this work in browser? Make it work.
|
|
5831
5827
|
if (source.url === null) {
|
|
5832
5828
|
throw new KnowledgeScrapeError('Website scraper requires URL');
|
|
5833
5829
|
}
|
|
@@ -5887,9 +5883,14 @@ var WebsiteScraper = /** @class */ (function () {
|
|
|
5887
5883
|
asJson: function () {
|
|
5888
5884
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
5889
5885
|
},
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5886
|
+
/*
|
|
5887
|
+
TODO: [🥽]
|
|
5888
|
+
> asBlob() {
|
|
5889
|
+
> throw new UnexpectedError(
|
|
5890
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
5891
|
+
> );
|
|
5892
|
+
> },
|
|
5893
|
+
*/
|
|
5893
5894
|
};
|
|
5894
5895
|
knowledge = this.markdownScraper.scrape(markdownSource);
|
|
5895
5896
|
return [4 /*yield*/, cacheFilehandler.destroy()];
|