@promptbook/website-crawler 0.82.0 → 0.83.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/esm/index.es.js +16 -16
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/editable.index.d.ts +74 -0
- package/esm/typings/src/_packages/types.index.d.ts +26 -0
- package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
- package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +1 -1
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/JOKER/JokerCommand.d.ts +1 -1
- package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -2
- package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.d.ts → knowledgeSourceContentToName.d.ts} +2 -2
- package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -1
- package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -1
- package/esm/typings/src/commands/PARAMETER/ParameterCommand.d.ts +1 -1
- package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +1 -1
- package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +1 -1
- package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
- package/esm/typings/src/commands/SECTION/sectionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/URL/UrlCommand.d.ts +1 -1
- package/esm/typings/src/commands/URL/urlCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/X_ACTION/ActionCommand.d.ts +1 -1
- package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +1 -1
- package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +8 -0
- package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +2 -0
- package/esm/typings/src/commands/index.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +16 -16
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.test.d.ts → knowledgeSourceContentToName.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.82.0
|
|
29
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3461,15 +3461,15 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
3461
3461
|
/**
|
|
3462
3462
|
* Creates unique name for the source
|
|
3463
3463
|
*
|
|
3464
|
-
* @
|
|
3464
|
+
* @public exported from `@promptbook/editable`
|
|
3465
3465
|
*/
|
|
3466
|
-
function
|
|
3467
|
-
var hash = SHA256(hexEncoder.parse(JSON.stringify(
|
|
3466
|
+
function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
3467
|
+
var hash = SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
|
|
3468
3468
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
3469
3469
|
.toString( /* hex */)
|
|
3470
3470
|
.substring(0, 20);
|
|
3471
3471
|
// <- TODO: [🥬] Make some system for hashes and ids of promptbook
|
|
3472
|
-
var semanticName = normalizeToKebabCase(
|
|
3472
|
+
var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
|
|
3473
3473
|
var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
|
|
3474
3474
|
var name = pieces.join('-').split('--').join('-');
|
|
3475
3475
|
// <- TODO: Use MAX_FILENAME_LENGTH
|
|
@@ -3569,19 +3569,19 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
3569
3569
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3570
3570
|
var _a;
|
|
3571
3571
|
return __awaiter(this, void 0, void 0, function () {
|
|
3572
|
-
var _b, fetch,
|
|
3572
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3573
3573
|
return __generator(this, function (_f) {
|
|
3574
3574
|
switch (_f.label) {
|
|
3575
3575
|
case 0:
|
|
3576
3576
|
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
3577
|
-
|
|
3577
|
+
knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
|
|
3578
3578
|
name = knowledgeSource.name;
|
|
3579
3579
|
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
3580
3580
|
if (!name) {
|
|
3581
|
-
name =
|
|
3581
|
+
name = knowledgeSourceContentToName(knowledgeSourceContent);
|
|
3582
3582
|
}
|
|
3583
|
-
if (!isValidUrl(
|
|
3584
|
-
url =
|
|
3583
|
+
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
|
|
3584
|
+
url = knowledgeSourceContent;
|
|
3585
3585
|
return [4 /*yield*/, fetch(url)];
|
|
3586
3586
|
case 1:
|
|
3587
3587
|
response_1 = _f.sent();
|
|
@@ -3627,7 +3627,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3627
3627
|
},
|
|
3628
3628
|
}];
|
|
3629
3629
|
case 2:
|
|
3630
|
-
if (!isValidFilePath(
|
|
3630
|
+
if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
|
|
3631
3631
|
if (tools.fs === undefined) {
|
|
3632
3632
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
3633
3633
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -3636,13 +3636,13 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3636
3636
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
3637
3637
|
// <- TODO: [🧠] What is the best error type here`
|
|
3638
3638
|
}
|
|
3639
|
-
filename_1 = join(rootDirname,
|
|
3639
|
+
filename_1 = join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
3640
3640
|
fileExtension = getFileExtension(filename_1);
|
|
3641
3641
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3642
3642
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3643
3643
|
case 3:
|
|
3644
3644
|
if (!(_f.sent())) {
|
|
3645
|
-
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(
|
|
3645
|
+
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(knowledgeSourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
|
|
3646
3646
|
}
|
|
3647
3647
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3648
3648
|
return [2 /*return*/, {
|
|
@@ -3693,7 +3693,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3693
3693
|
url: null,
|
|
3694
3694
|
mimeType: 'text/markdown',
|
|
3695
3695
|
asText: function () {
|
|
3696
|
-
return knowledgeSource.
|
|
3696
|
+
return knowledgeSource.knowledgeSourceContent;
|
|
3697
3697
|
},
|
|
3698
3698
|
asJson: function () {
|
|
3699
3699
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
@@ -3755,7 +3755,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3755
3755
|
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
3756
3756
|
return [2 /*return*/, "break"];
|
|
3757
3757
|
}
|
|
3758
|
-
console.warn(spaceTrim$1(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.
|
|
3758
|
+
console.warn(spaceTrim$1(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.knowledgeSourceContent
|
|
3759
3759
|
.split('\n')
|
|
3760
3760
|
.map(function (line) { return "> ".concat(line); })
|
|
3761
3761
|
.join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|
|
@@ -3793,7 +3793,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3793
3793
|
return [7 /*endfinally*/];
|
|
3794
3794
|
case 9:
|
|
3795
3795
|
if (partialPieces === null) {
|
|
3796
|
-
throw new KnowledgeScrapeError(spaceTrim$1(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.
|
|
3796
|
+
throw new KnowledgeScrapeError(spaceTrim$1(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
|
|
3797
3797
|
.split('\n')
|
|
3798
3798
|
.map(function (line) { return "> ".concat(line); })
|
|
3799
3799
|
.join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
|