@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.
Files changed (44) hide show
  1. package/esm/index.es.js +16 -16
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/editable.index.d.ts +74 -0
  4. package/esm/typings/src/_packages/types.index.d.ts +26 -0
  5. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
  6. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +1 -1
  7. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +1 -1
  8. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -1
  9. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
  10. package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +1 -1
  11. package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +1 -1
  12. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
  13. package/esm/typings/src/commands/JOKER/JokerCommand.d.ts +1 -1
  14. package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +1 -1
  15. package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -2
  16. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +1 -1
  17. package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.d.ts → knowledgeSourceContentToName.d.ts} +2 -2
  18. package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -1
  19. package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -1
  20. package/esm/typings/src/commands/PARAMETER/ParameterCommand.d.ts +1 -1
  21. package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +1 -1
  22. package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +1 -1
  23. package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +1 -1
  24. package/esm/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +1 -1
  25. package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +1 -1
  26. package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
  27. package/esm/typings/src/commands/SECTION/sectionCommandParser.d.ts +1 -1
  28. package/esm/typings/src/commands/URL/UrlCommand.d.ts +1 -1
  29. package/esm/typings/src/commands/URL/urlCommandParser.d.ts +1 -1
  30. package/esm/typings/src/commands/X_ACTION/ActionCommand.d.ts +1 -1
  31. package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +1 -1
  32. package/esm/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +1 -1
  33. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +1 -1
  34. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
  35. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  36. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -0
  37. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +8 -0
  38. package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +2 -0
  39. package/esm/typings/src/commands/index.d.ts +1 -1
  40. package/esm/typings/src/pipeline/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  41. package/package.json +2 -2
  42. package/umd/index.umd.js +16 -16
  43. package/umd/index.umd.js.map +1 -1
  44. /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-3';
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
- * @private within the repository
3464
+ * @public exported from `@promptbook/editable`
3465
3465
  */
3466
- function sourceContentToName(sourceContent) {
3467
- var hash = SHA256(hexEncoder.parse(JSON.stringify(sourceContent)))
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(sourceContent.substring(0, 20));
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, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
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
- sourceContent = knowledgeSource.sourceContent;
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 = sourceContentToName(sourceContent);
3581
+ name = knowledgeSourceContentToName(knowledgeSourceContent);
3582
3582
  }
3583
- if (!isValidUrl(sourceContent)) return [3 /*break*/, 2];
3584
- url = sourceContent;
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(sourceContent)) return [3 /*break*/, 4];
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, sourceContent).split('\\').join('/');
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(sourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
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.sourceContent;
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.sourceContent
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.sourceContent
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 "); }));