@promptbook/documents 0.82.0 → 0.84.0-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 (52) hide show
  1. package/README.md +4 -0
  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 +82 -2
  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/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +17 -0
  43. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +10 -0
  44. package/esm/typings/src/utils/editable/{utils → edit-pipeline-string}/removePipelineCommand.d.ts +1 -1
  45. package/esm/typings/src/utils/editable/edit-pipeline-string/removePipelineCommand.test.d.ts +1 -0
  46. package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +7 -0
  47. package/esm/typings/src/utils/editable/utils/renamePipelineParameter.d.ts +3 -0
  48. package/package.json +2 -2
  49. package/umd/index.umd.js +16 -16
  50. package/umd/index.umd.js.map +1 -1
  51. /package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.test.d.ts → knowledgeSourceContentToName.test.d.ts} +0 -0
  52. /package/esm/typings/src/utils/editable/{utils/removePipelineCommand.test.d.ts → edit-pipeline-string/addPipelineCommand.test.d.ts} +0 -0
package/README.md CHANGED
@@ -23,6 +23,10 @@
23
23
 
24
24
 
25
25
 
26
+ <blockquote style="color: #ff8811">
27
+ <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
28
+ </blockquote>
29
+
26
30
  ## 📦 Package `@promptbook/documents`
27
31
 
28
32
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
package/esm/index.es.js CHANGED
@@ -25,7 +25,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- var PROMPTBOOK_ENGINE_VERSION = '0.82.0-3';
28
+ var PROMPTBOOK_ENGINE_VERSION = '0.83.0';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3648,15 +3648,15 @@ function $registeredScrapersMessage(availableScrapers) {
3648
3648
  /**
3649
3649
  * Creates unique name for the source
3650
3650
  *
3651
- * @private within the repository
3651
+ * @public exported from `@promptbook/editable`
3652
3652
  */
3653
- function sourceContentToName(sourceContent) {
3654
- var hash = SHA256(hexEncoder.parse(JSON.stringify(sourceContent)))
3653
+ function knowledgeSourceContentToName(knowledgeSourceContent) {
3654
+ var hash = SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
3655
3655
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
3656
3656
  .toString( /* hex */)
3657
3657
  .substring(0, 20);
3658
3658
  // <- TODO: [🥬] Make some system for hashes and ids of promptbook
3659
- var semanticName = normalizeToKebabCase(sourceContent.substring(0, 20));
3659
+ var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
3660
3660
  var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
3661
3661
  var name = pieces.join('-').split('--').join('-');
3662
3662
  // <- TODO: Use MAX_FILENAME_LENGTH
@@ -3710,19 +3710,19 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
3710
3710
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3711
3711
  var _a;
3712
3712
  return __awaiter(this, void 0, void 0, function () {
3713
- var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3713
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3714
3714
  return __generator(this, function (_f) {
3715
3715
  switch (_f.label) {
3716
3716
  case 0:
3717
3717
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
3718
- sourceContent = knowledgeSource.sourceContent;
3718
+ knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
3719
3719
  name = knowledgeSource.name;
3720
3720
  _c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
3721
3721
  if (!name) {
3722
- name = sourceContentToName(sourceContent);
3722
+ name = knowledgeSourceContentToName(knowledgeSourceContent);
3723
3723
  }
3724
- if (!isValidUrl(sourceContent)) return [3 /*break*/, 2];
3725
- url = sourceContent;
3724
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
3725
+ url = knowledgeSourceContent;
3726
3726
  return [4 /*yield*/, fetch(url)];
3727
3727
  case 1:
3728
3728
  response_1 = _f.sent();
@@ -3768,7 +3768,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3768
3768
  },
3769
3769
  }];
3770
3770
  case 2:
3771
- if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
3771
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
3772
3772
  if (tools.fs === undefined) {
3773
3773
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
3774
3774
  // <- TODO: [🧠] What is the best error type here`
@@ -3777,13 +3777,13 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3777
3777
  throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
3778
3778
  // <- TODO: [🧠] What is the best error type here`
3779
3779
  }
3780
- filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
3780
+ filename_1 = join(rootDirname, knowledgeSourceContent).split('\\').join('/');
3781
3781
  fileExtension = getFileExtension(filename_1);
3782
3782
  mimeType = extensionToMimeType(fileExtension || '');
3783
3783
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3784
3784
  case 3:
3785
3785
  if (!(_f.sent())) {
3786
- 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 "); }));
3786
+ 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 "); }));
3787
3787
  }
3788
3788
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
3789
3789
  return [2 /*return*/, {
@@ -3834,7 +3834,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3834
3834
  url: null,
3835
3835
  mimeType: 'text/markdown',
3836
3836
  asText: function () {
3837
- return knowledgeSource.sourceContent;
3837
+ return knowledgeSource.knowledgeSourceContent;
3838
3838
  },
3839
3839
  asJson: function () {
3840
3840
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
@@ -3896,7 +3896,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
3896
3896
  partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
3897
3897
  return [2 /*return*/, "break"];
3898
3898
  }
3899
- 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
3899
+ 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
3900
3900
  .split('\n')
3901
3901
  .map(function (line) { return "> ".concat(line); })
3902
3902
  .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -3934,7 +3934,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
3934
3934
  return [7 /*endfinally*/];
3935
3935
  case 9:
3936
3936
  if (partialPieces === null) {
3937
- throw new KnowledgeScrapeError(spaceTrim$1(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.sourceContent
3937
+ throw new KnowledgeScrapeError(spaceTrim$1(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
3938
3938
  .split('\n')
3939
3939
  .map(function (line) { return "> ".concat(line); })
3940
3940
  .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));