@promptbook/pdf 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/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-3';
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
@@ -3274,15 +3274,15 @@
3274
3274
  /**
3275
3275
  * Creates unique name for the source
3276
3276
  *
3277
- * @private within the repository
3277
+ * @public exported from `@promptbook/editable`
3278
3278
  */
3279
- function sourceContentToName(sourceContent) {
3280
- var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(sourceContent)))
3279
+ function knowledgeSourceContentToName(knowledgeSourceContent) {
3280
+ var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(knowledgeSourceContent)))
3281
3281
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
3282
3282
  .toString( /* hex */)
3283
3283
  .substring(0, 20);
3284
3284
  // <- TODO: [🥬] Make some system for hashes and ids of promptbook
3285
- var semanticName = normalizeToKebabCase(sourceContent.substring(0, 20));
3285
+ var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
3286
3286
  var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
3287
3287
  var name = pieces.join('-').split('--').join('-');
3288
3288
  // <- TODO: Use MAX_FILENAME_LENGTH
@@ -3431,19 +3431,19 @@
3431
3431
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3432
3432
  var _a;
3433
3433
  return __awaiter(this, void 0, void 0, function () {
3434
- var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3434
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3435
3435
  return __generator(this, function (_f) {
3436
3436
  switch (_f.label) {
3437
3437
  case 0:
3438
3438
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
3439
- sourceContent = knowledgeSource.sourceContent;
3439
+ knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
3440
3440
  name = knowledgeSource.name;
3441
3441
  _c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
3442
3442
  if (!name) {
3443
- name = sourceContentToName(sourceContent);
3443
+ name = knowledgeSourceContentToName(knowledgeSourceContent);
3444
3444
  }
3445
- if (!isValidUrl(sourceContent)) return [3 /*break*/, 2];
3446
- url = sourceContent;
3445
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
3446
+ url = knowledgeSourceContent;
3447
3447
  return [4 /*yield*/, fetch(url)];
3448
3448
  case 1:
3449
3449
  response_1 = _f.sent();
@@ -3489,7 +3489,7 @@
3489
3489
  },
3490
3490
  }];
3491
3491
  case 2:
3492
- if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
3492
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
3493
3493
  if (tools.fs === undefined) {
3494
3494
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
3495
3495
  // <- TODO: [🧠] What is the best error type here`
@@ -3498,13 +3498,13 @@
3498
3498
  throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
3499
3499
  // <- TODO: [🧠] What is the best error type here`
3500
3500
  }
3501
- filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
3501
+ filename_1 = path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
3502
3502
  fileExtension = getFileExtension(filename_1);
3503
3503
  mimeType = extensionToMimeType(fileExtension || '');
3504
3504
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3505
3505
  case 3:
3506
3506
  if (!(_f.sent())) {
3507
- 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 "); }));
3507
+ 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 "); }));
3508
3508
  }
3509
3509
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
3510
3510
  return [2 /*return*/, {
@@ -3555,7 +3555,7 @@
3555
3555
  url: null,
3556
3556
  mimeType: 'text/markdown',
3557
3557
  asText: function () {
3558
- return knowledgeSource.sourceContent;
3558
+ return knowledgeSource.knowledgeSourceContent;
3559
3559
  },
3560
3560
  asJson: function () {
3561
3561
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
@@ -3617,7 +3617,7 @@
3617
3617
  partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
3618
3618
  return [2 /*return*/, "break"];
3619
3619
  }
3620
- 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
3620
+ 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
3621
3621
  .split('\n')
3622
3622
  .map(function (line) { return "> ".concat(line); })
3623
3623
  .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -3655,7 +3655,7 @@
3655
3655
  return [7 /*endfinally*/];
3656
3656
  case 9:
3657
3657
  if (partialPieces === null) {
3658
- throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.sourceContent
3658
+ throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
3659
3659
  .split('\n')
3660
3660
  .map(function (line) { return "> ".concat(line); })
3661
3661
  .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));