@promptbook/markdown-utils 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 +1 -1
  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
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
22
22
  * @generated
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.82.0-3';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3427,15 +3427,15 @@ function normalizeToKebabCase(text) {
3427
3427
  /**
3428
3428
  * Creates unique name for the source
3429
3429
  *
3430
- * @private within the repository
3430
+ * @public exported from `@promptbook/editable`
3431
3431
  */
3432
- function sourceContentToName(sourceContent) {
3433
- var hash = SHA256(hexEncoder.parse(JSON.stringify(sourceContent)))
3432
+ function knowledgeSourceContentToName(knowledgeSourceContent) {
3433
+ var hash = SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
3434
3434
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
3435
3435
  .toString( /* hex */)
3436
3436
  .substring(0, 20);
3437
3437
  // <- TODO: [🥬] Make some system for hashes and ids of promptbook
3438
- var semanticName = normalizeToKebabCase(sourceContent.substring(0, 20));
3438
+ var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
3439
3439
  var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
3440
3440
  var name = pieces.join('-').split('--').join('-');
3441
3441
  // <- TODO: Use MAX_FILENAME_LENGTH
@@ -3584,19 +3584,19 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
3584
3584
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3585
3585
  var _a;
3586
3586
  return __awaiter(this, void 0, void 0, function () {
3587
- var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3587
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3588
3588
  return __generator(this, function (_f) {
3589
3589
  switch (_f.label) {
3590
3590
  case 0:
3591
3591
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
3592
- sourceContent = knowledgeSource.sourceContent;
3592
+ knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
3593
3593
  name = knowledgeSource.name;
3594
3594
  _c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
3595
3595
  if (!name) {
3596
- name = sourceContentToName(sourceContent);
3596
+ name = knowledgeSourceContentToName(knowledgeSourceContent);
3597
3597
  }
3598
- if (!isValidUrl(sourceContent)) return [3 /*break*/, 2];
3599
- url = sourceContent;
3598
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
3599
+ url = knowledgeSourceContent;
3600
3600
  return [4 /*yield*/, fetch(url)];
3601
3601
  case 1:
3602
3602
  response_1 = _f.sent();
@@ -3642,7 +3642,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3642
3642
  },
3643
3643
  }];
3644
3644
  case 2:
3645
- if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
3645
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
3646
3646
  if (tools.fs === undefined) {
3647
3647
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
3648
3648
  // <- TODO: [🧠] What is the best error type here`
@@ -3651,13 +3651,13 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3651
3651
  throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
3652
3652
  // <- TODO: [🧠] What is the best error type here`
3653
3653
  }
3654
- filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
3654
+ filename_1 = join(rootDirname, knowledgeSourceContent).split('\\').join('/');
3655
3655
  fileExtension = getFileExtension(filename_1);
3656
3656
  mimeType = extensionToMimeType(fileExtension || '');
3657
3657
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3658
3658
  case 3:
3659
3659
  if (!(_f.sent())) {
3660
- throw new NotFoundError(spaceTrim(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 "); }));
3660
+ throw new NotFoundError(spaceTrim(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 "); }));
3661
3661
  }
3662
3662
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
3663
3663
  return [2 /*return*/, {
@@ -3708,7 +3708,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3708
3708
  url: null,
3709
3709
  mimeType: 'text/markdown',
3710
3710
  asText: function () {
3711
- return knowledgeSource.sourceContent;
3711
+ return knowledgeSource.knowledgeSourceContent;
3712
3712
  },
3713
3713
  asJson: function () {
3714
3714
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
@@ -3770,7 +3770,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
3770
3770
  partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
3771
3771
  return [2 /*return*/, "break"];
3772
3772
  }
3773
- console.warn(spaceTrim(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
3773
+ console.warn(spaceTrim(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
3774
3774
  .split('\n')
3775
3775
  .map(function (line) { return "> ".concat(line); })
3776
3776
  .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -3808,7 +3808,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
3808
3808
  return [7 /*endfinally*/];
3809
3809
  case 9:
3810
3810
  if (partialPieces === null) {
3811
- throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.sourceContent
3811
+ throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
3812
3812
  .split('\n')
3813
3813
  .map(function (line) { return "> ".concat(line); })
3814
3814
  .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));