@promptbook/website-crawler 0.71.0-20 → 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 -42
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/{scrapers/_common/register → executables}/$provideExecutablesForNode.d.ts +3 -3
- package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
- package/esm/typings/src/executables/apps/locateLibreoffice.test.d.ts +1 -0
- package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
- package/esm/typings/src/executables/apps/locatePandoc.test.d.ts +1 -0
- package/esm/typings/src/executables/locateApp.d.ts +33 -0
- package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
- package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -4
- package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
- package/package.json +2 -2
- package/umd/index.umd.js +42 -42
- 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
|
/*! *****************************************************************************
|
|
@@ -2920,7 +2920,6 @@ var $scrapersRegister = new $Register('scraper_constructors');
|
|
|
2920
2920
|
* TODO: [®] DRY Register logic
|
|
2921
2921
|
*/
|
|
2922
2922
|
|
|
2923
|
-
// TODO: !!!!!!last - Maybe delete this function
|
|
2924
2923
|
/**
|
|
2925
2924
|
* Creates a message with all registered scrapers
|
|
2926
2925
|
*
|
|
@@ -3108,7 +3107,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3108
3107
|
return __awaiter(this, void 0, void 0, function () {
|
|
3109
3108
|
var sourceContent, name, _b, _c, rootDirname, _d,
|
|
3110
3109
|
// <- TODO: process.cwd() if running in Node.js
|
|
3111
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension,
|
|
3110
|
+
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3112
3111
|
return __generator(this, function (_e) {
|
|
3113
3112
|
switch (_e.label) {
|
|
3114
3113
|
case 0:
|
|
@@ -3130,19 +3129,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3130
3129
|
filename: null,
|
|
3131
3130
|
url: url,
|
|
3132
3131
|
mimeType: mimeType,
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
return [2 /*return*/, content];
|
|
3142
|
-
}
|
|
3143
|
-
});
|
|
3144
|
-
});
|
|
3145
|
-
},
|
|
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
|
+
*/
|
|
3146
3140
|
asJson: function () {
|
|
3147
3141
|
return __awaiter(this, void 0, void 0, function () {
|
|
3148
3142
|
var content;
|
|
@@ -3182,34 +3176,31 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3182
3176
|
}
|
|
3183
3177
|
filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
|
|
3184
3178
|
fileExtension = getFileExtension(filename_1);
|
|
3185
|
-
|
|
3179
|
+
mimeType = extensionToMimeType(fileExtension || '');
|
|
3186
3180
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3187
3181
|
case 3:
|
|
3188
3182
|
if (!(_e.sent())) {
|
|
3189
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 "); }));
|
|
3190
3184
|
}
|
|
3191
|
-
// TODO:
|
|
3185
|
+
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3192
3186
|
return [2 /*return*/, {
|
|
3193
3187
|
source: name,
|
|
3194
3188
|
filename: filename_1,
|
|
3195
3189
|
url: null,
|
|
3196
|
-
mimeType:
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
});
|
|
3211
|
-
});
|
|
3212
|
-
},
|
|
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
|
+
*/
|
|
3213
3204
|
asJson: function () {
|
|
3214
3205
|
return __awaiter(this, void 0, void 0, function () {
|
|
3215
3206
|
var _a, _b;
|
|
@@ -3245,9 +3236,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3245
3236
|
asJson: function () {
|
|
3246
3237
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
3247
3238
|
},
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
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
|
+
*/
|
|
3251
3247
|
}];
|
|
3252
3248
|
}
|
|
3253
3249
|
});
|
|
@@ -5828,7 +5824,6 @@ var WebsiteScraper = /** @class */ (function () {
|
|
|
5828
5824
|
switch (_g.label) {
|
|
5829
5825
|
case 0:
|
|
5830
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;
|
|
5831
|
-
// TODO: !!!!!! Does this work in browser? Make it work.
|
|
5832
5827
|
if (source.url === null) {
|
|
5833
5828
|
throw new KnowledgeScrapeError('Website scraper requires URL');
|
|
5834
5829
|
}
|
|
@@ -5888,9 +5883,14 @@ var WebsiteScraper = /** @class */ (function () {
|
|
|
5888
5883
|
asJson: function () {
|
|
5889
5884
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
5890
5885
|
},
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
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
|
+
*/
|
|
5894
5894
|
};
|
|
5895
5895
|
knowledge = this.markdownScraper.scrape(markdownSource);
|
|
5896
5896
|
return [4 /*yield*/, cacheFilehandler.destroy()];
|