@promptbook/markdown-utils 0.82.0-3 → 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 (45) hide show
  1. package/README.md +0 -4
  2. package/esm/index.es.js +16 -16
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/editable.index.d.ts +74 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +26 -0
  6. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
  7. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +1 -1
  8. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +1 -1
  9. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -1
  10. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
  11. package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +1 -1
  12. package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +1 -1
  13. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
  14. package/esm/typings/src/commands/JOKER/JokerCommand.d.ts +1 -1
  15. package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +1 -1
  16. package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -2
  17. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +1 -1
  18. package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.d.ts → knowledgeSourceContentToName.d.ts} +2 -2
  19. package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -1
  20. package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -1
  21. package/esm/typings/src/commands/PARAMETER/ParameterCommand.d.ts +1 -1
  22. package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +1 -1
  23. package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +1 -1
  24. package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +1 -1
  25. package/esm/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +1 -1
  26. package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +1 -1
  27. package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
  28. package/esm/typings/src/commands/SECTION/sectionCommandParser.d.ts +1 -1
  29. package/esm/typings/src/commands/URL/UrlCommand.d.ts +1 -1
  30. package/esm/typings/src/commands/URL/urlCommandParser.d.ts +1 -1
  31. package/esm/typings/src/commands/X_ACTION/ActionCommand.d.ts +1 -1
  32. package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +1 -1
  33. package/esm/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +1 -1
  34. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +1 -1
  35. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
  36. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  37. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -0
  38. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +8 -0
  39. package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +2 -0
  40. package/esm/typings/src/commands/index.d.ts +1 -1
  41. package/esm/typings/src/pipeline/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  42. package/package.json +1 -1
  43. package/umd/index.umd.js +16 -16
  44. package/umd/index.umd.js.map +1 -1
  45. /package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.test.d.ts → knowledgeSourceContentToName.test.d.ts} +0 -0
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.82.0-2';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3429,15 +3429,15 @@
3429
3429
  /**
3430
3430
  * Creates unique name for the source
3431
3431
  *
3432
- * @private within the repository
3432
+ * @public exported from `@promptbook/editable`
3433
3433
  */
3434
- function sourceContentToName(sourceContent) {
3435
- var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(sourceContent)))
3434
+ function knowledgeSourceContentToName(knowledgeSourceContent) {
3435
+ var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(knowledgeSourceContent)))
3436
3436
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
3437
3437
  .toString( /* hex */)
3438
3438
  .substring(0, 20);
3439
3439
  // <- TODO: [🥬] Make some system for hashes and ids of promptbook
3440
- var semanticName = normalizeToKebabCase(sourceContent.substring(0, 20));
3440
+ var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
3441
3441
  var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
3442
3442
  var name = pieces.join('-').split('--').join('-');
3443
3443
  // <- TODO: Use MAX_FILENAME_LENGTH
@@ -3586,19 +3586,19 @@
3586
3586
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3587
3587
  var _a;
3588
3588
  return __awaiter(this, void 0, void 0, function () {
3589
- var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3589
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3590
3590
  return __generator(this, function (_f) {
3591
3591
  switch (_f.label) {
3592
3592
  case 0:
3593
3593
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
3594
- sourceContent = knowledgeSource.sourceContent;
3594
+ knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
3595
3595
  name = knowledgeSource.name;
3596
3596
  _c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
3597
3597
  if (!name) {
3598
- name = sourceContentToName(sourceContent);
3598
+ name = knowledgeSourceContentToName(knowledgeSourceContent);
3599
3599
  }
3600
- if (!isValidUrl(sourceContent)) return [3 /*break*/, 2];
3601
- url = sourceContent;
3600
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
3601
+ url = knowledgeSourceContent;
3602
3602
  return [4 /*yield*/, fetch(url)];
3603
3603
  case 1:
3604
3604
  response_1 = _f.sent();
@@ -3644,7 +3644,7 @@
3644
3644
  },
3645
3645
  }];
3646
3646
  case 2:
3647
- if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
3647
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
3648
3648
  if (tools.fs === undefined) {
3649
3649
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
3650
3650
  // <- TODO: [🧠] What is the best error type here`
@@ -3653,13 +3653,13 @@
3653
3653
  throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
3654
3654
  // <- TODO: [🧠] What is the best error type here`
3655
3655
  }
3656
- filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
3656
+ filename_1 = path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
3657
3657
  fileExtension = getFileExtension(filename_1);
3658
3658
  mimeType = extensionToMimeType(fileExtension || '');
3659
3659
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3660
3660
  case 3:
3661
3661
  if (!(_f.sent())) {
3662
- throw new NotFoundError(spaceTrim__default["default"](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 "); }));
3662
+ throw new NotFoundError(spaceTrim__default["default"](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 "); }));
3663
3663
  }
3664
3664
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
3665
3665
  return [2 /*return*/, {
@@ -3710,7 +3710,7 @@
3710
3710
  url: null,
3711
3711
  mimeType: 'text/markdown',
3712
3712
  asText: function () {
3713
- return knowledgeSource.sourceContent;
3713
+ return knowledgeSource.knowledgeSourceContent;
3714
3714
  },
3715
3715
  asJson: function () {
3716
3716
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
@@ -3772,7 +3772,7 @@
3772
3772
  partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
3773
3773
  return [2 /*return*/, "break"];
3774
3774
  }
3775
- console.warn(spaceTrim__default["default"](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
3775
+ console.warn(spaceTrim__default["default"](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
3776
3776
  .split('\n')
3777
3777
  .map(function (line) { return "> ".concat(line); })
3778
3778
  .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -3810,7 +3810,7 @@
3810
3810
  return [7 /*endfinally*/];
3811
3811
  case 9:
3812
3812
  if (partialPieces === null) {
3813
- throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.sourceContent
3813
+ throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
3814
3814
  .split('\n')
3815
3815
  .map(function (line) { return "> ".concat(line); })
3816
3816
  .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));