@promptbook/legacy-documents 0.92.0-23 → 0.92.0-25

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 (83) hide show
  1. package/esm/index.es.js +67 -43
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +0 -2
  4. package/esm/typings/src/collection/PipelineCollection.d.ts +0 -2
  5. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
  6. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
  7. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +36 -28
  8. package/esm/typings/src/config.d.ts +8 -4
  9. package/esm/typings/src/constants.d.ts +2 -2
  10. package/esm/typings/src/errors/0-BoilerplateError.d.ts +2 -2
  11. package/esm/typings/src/execution/CommonToolsOptions.d.ts +3 -3
  12. package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +10 -10
  13. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +3 -2
  14. package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +2 -1
  15. package/esm/typings/src/formfactors/index.d.ts +1 -1
  16. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +3 -2
  17. package/esm/typings/src/llm-providers/_common/register/$llmToolsMetadataRegister.d.ts +3 -3
  18. package/esm/typings/src/llm-providers/_common/register/$llmToolsRegister.d.ts +3 -3
  19. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +4 -4
  20. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +5 -5
  21. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +5 -3
  22. package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +3 -3
  23. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +5 -5
  24. package/esm/typings/src/other/templates/getBookTemplates.d.ts +2 -2
  25. package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +3 -3
  26. package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +1 -1
  27. package/esm/typings/src/pipeline/PipelineInterface/getPipelineInterface.d.ts +1 -1
  28. package/esm/typings/src/pipeline/PipelineInterface/isPipelineImplementingInterface.d.ts +5 -4
  29. package/esm/typings/src/pipeline/PipelineInterface/isPipelineInterfacesEqual.d.ts +1 -1
  30. package/esm/typings/src/pipeline/PipelineJson/CommonTaskJson.d.ts +9 -6
  31. package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +2 -2
  32. package/esm/typings/src/pipeline/PipelineString.d.ts +3 -1
  33. package/esm/typings/src/pipeline/book-notation.d.ts +2 -2
  34. package/esm/typings/src/prepare/prepareTasks.d.ts +7 -4
  35. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +2 -1
  36. package/esm/typings/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +3 -3
  37. package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -1
  38. package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -1
  39. package/esm/typings/src/scrapers/_common/Converter.d.ts +3 -1
  40. package/esm/typings/src/scrapers/_common/Scraper.d.ts +4 -3
  41. package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +4 -2
  42. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -1
  43. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +6 -3
  44. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +3 -5
  45. package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +3 -2
  46. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +8 -5
  47. package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +2 -1
  48. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +6 -5
  49. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +3 -1
  50. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
  51. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +2 -1
  52. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +4 -1
  53. package/esm/typings/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
  54. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +2 -1
  55. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -4
  56. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +5 -1
  57. package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +12 -5
  58. package/esm/typings/src/storage/file-cache-storage/FileCacheStorageOptions.d.ts +4 -2
  59. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +2 -1
  60. package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.d.ts +2 -1
  61. package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +2 -1
  62. package/esm/typings/src/types/ModelVariant.d.ts +5 -5
  63. package/esm/typings/src/types/typeAliases.d.ts +8 -6
  64. package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +2 -2
  65. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +4 -1
  66. package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +2 -1
  67. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -1
  68. package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +1 -1
  69. package/esm/typings/src/utils/normalization/nameToUriPart.d.ts +4 -4
  70. package/esm/typings/src/utils/normalization/nameToUriParts.d.ts +4 -4
  71. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -3
  72. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +3 -3
  73. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +4 -4
  74. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +3 -3
  75. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +3 -3
  76. package/esm/typings/src/utils/normalization/searchKeywords.d.ts +4 -1
  77. package/esm/typings/src/utils/normalization/titleToName.d.ts +4 -4
  78. package/esm/typings/src/utils/organization/empty_object.d.ts +2 -2
  79. package/esm/typings/src/utils/organization/just_empty_object.d.ts +4 -4
  80. package/esm/typings/src/version.d.ts +2 -1
  81. package/package.json +2 -2
  82. package/umd/index.umd.js +67 -43
  83. package/umd/index.umd.js.map +1 -1
package/esm/index.es.js CHANGED
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-23';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-25';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -105,11 +105,20 @@ const DEFAULT_BOOK_TITLE = `✨ Untitled Book`;
105
105
  */
106
106
  const DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
107
107
  /**
108
- * @@@
108
+ * Threshold value that determines when a dataset is considered "big"
109
+ * and may require special handling or optimizations
110
+ *
111
+ * For example, when error occurs in one item of the big dataset, it will not fail the whole pipeline
109
112
  *
110
113
  * @public exported from `@promptbook/core`
111
114
  */
112
115
  const BIG_DATASET_TRESHOLD = 50;
116
+ /**
117
+ * Placeholder text used to represent a placeholder value of failed operation
118
+ *
119
+ * @public exported from `@promptbook/core`
120
+ */
121
+ const FAILED_VALUE_PLACEHOLDER = '!?';
113
122
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
114
123
  /**
115
124
  * The maximum number of iterations for a loops
@@ -553,7 +562,8 @@ async function isFileExisting(filename, fs) {
553
562
  */
554
563
 
555
564
  /**
556
- * @@@
565
+ * Converts a name to a properly formatted subfolder path for cache storage.
566
+ * Handles normalization and path formatting to create consistent cache directory structures.
557
567
  *
558
568
  * @private for `FileCacheStorage`
559
569
  */
@@ -806,10 +816,10 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
806
816
  */
807
817
 
808
818
  /**
809
- * @@@
819
+ * Removes diacritic marks (accents) from characters in a string.
810
820
  *
811
- * @param input @@@
812
- * @returns @@@
821
+ * @param input The string containing diacritics to be normalized.
822
+ * @returns The string with diacritics removed or normalized.
813
823
  * @public exported from `@promptbook/utils`
814
824
  */
815
825
  function removeDiacritics(input) {
@@ -823,10 +833,10 @@ function removeDiacritics(input) {
823
833
  */
824
834
 
825
835
  /**
826
- * @@@
836
+ * Converts a given text to kebab-case format.
827
837
  *
828
- * @param text @@@
829
- * @returns @@@
838
+ * @param text The text to be converted.
839
+ * @returns The kebab-case formatted string.
830
840
  * @example 'hello-world'
831
841
  * @example 'i-love-promptbook'
832
842
  * @public exported from `@promptbook/utils`
@@ -968,11 +978,11 @@ function isValidUrl(url) {
968
978
  }
969
979
 
970
980
  /**
971
- * @@@
981
+ * Converts a title string into a normalized name.
972
982
  *
973
- * @param value @@@
974
- * @returns @@@
975
- * @example @@@
983
+ * @param value The title string to be converted to a name.
984
+ * @returns A normalized name derived from the input title.
985
+ * @example 'Hello World!' -> 'hello-world'
976
986
  * @public exported from `@promptbook/utils`
977
987
  */
978
988
  function titleToName(value) {
@@ -992,9 +1002,8 @@ function titleToName(value) {
992
1002
  }
993
1003
 
994
1004
  /**
995
- * Create a filename for intermediate cache for scrapers
996
- *
997
- * Note: It also checks if directory exists and creates it if not
1005
+ * Retrieves an intermediate source for a scraper based on the knowledge source.
1006
+ * Manages the caching and retrieval of intermediate scraper results for optimized performance.
998
1007
  *
999
1008
  * @private as internal utility for scrapers
1000
1009
  */
@@ -1628,13 +1637,13 @@ const ORDER_OF_PIPELINE_JSON = [
1628
1637
  */
1629
1638
  const REPLACING_NONCE = 'ptbkauk42kV2dzao34faw7FudQUHYPtW';
1630
1639
  /**
1631
- * @@@
1640
+ * Placeholder value indicating a parameter is missing its value.
1632
1641
  *
1633
1642
  * @private within the repository
1634
1643
  */
1635
1644
  const RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
1636
1645
  /**
1637
- * @@@
1646
+ * Placeholder value indicating a parameter is restricted and cannot be used directly.
1638
1647
  *
1639
1648
  * @private within the repository
1640
1649
  */
@@ -2133,7 +2142,7 @@ class SimplePipelineCollection {
2133
2142
  /**
2134
2143
  * Constructs a pipeline collection from pipelines
2135
2144
  *
2136
- * @param pipelines @@@
2145
+ * @param pipelines Array of pipeline JSON objects to include in the collection
2137
2146
  *
2138
2147
  * Note: During the construction logic of all pipelines are validated
2139
2148
  * Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
@@ -2279,8 +2288,8 @@ class PipelineExecutionError extends Error {
2279
2288
  * @public exported from `@promptbook/core`
2280
2289
  */
2281
2290
  function isPipelinePrepared(pipeline) {
2282
- // Note: Ignoring `pipeline.preparations` @@@
2283
- // Note: Ignoring `pipeline.knowledgePieces` @@@
2291
+ // Note: Ignoring `pipeline.preparations`
2292
+ // Note: Ignoring `pipeline.knowledgePieces`
2284
2293
  if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
2285
2294
  // TODO: !!! Comment this out
2286
2295
  console.log('Pipeline is not prepared because title is undefined or empty', pipeline);
@@ -3252,7 +3261,8 @@ async function preparePersona(personaDescription, tools, options) {
3252
3261
  */
3253
3262
 
3254
3263
  /**
3255
- * @@@
3264
+ * Safely retrieves the global scope object (window in browser, global in Node.js)
3265
+ * regardless of the JavaScript environment in which the code is running
3256
3266
  *
3257
3267
  * Note: `$` is used to indicate that this function is not a pure function - it access global scope
3258
3268
  *
@@ -3263,10 +3273,10 @@ function $getGlobalScope() {
3263
3273
  }
3264
3274
 
3265
3275
  /**
3266
- * @@@
3276
+ * Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
3267
3277
  *
3268
- * @param text @@@
3269
- * @returns @@@
3278
+ * @param text The text string to be converted to SCREAMING_CASE format.
3279
+ * @returns The normalized text in SCREAMING_CASE format.
3270
3280
  * @example 'HELLO_WORLD'
3271
3281
  * @example 'I_LOVE_PROMPTBOOK'
3272
3282
  * @public exported from `@promptbook/utils`
@@ -3318,10 +3328,10 @@ function normalizeTo_SCREAMING_CASE(text) {
3318
3328
  */
3319
3329
 
3320
3330
  /**
3321
- * @@@
3331
+ * Normalizes a text string to snake_case format.
3322
3332
  *
3323
- * @param text @@@
3324
- * @returns @@@
3333
+ * @param text The text string to be converted to snake_case format.
3334
+ * @returns The normalized text in snake_case format.
3325
3335
  * @example 'hello_world'
3326
3336
  * @example 'i_love_promptbook'
3327
3337
  * @public exported from `@promptbook/utils`
@@ -3391,10 +3401,11 @@ const $scrapersMetadataRegister = new $Register('scrapers_metadata');
3391
3401
  */
3392
3402
 
3393
3403
  /**
3394
- * @@@
3404
+ * Registry for all available scrapers in the system.
3405
+ * Central point for registering and accessing different types of content scrapers.
3395
3406
  *
3396
3407
  * Note: `$` is used to indicate that this interacts with the global scope
3397
- * @singleton Only one instance of each register is created per build, but thare can be more @@@
3408
+ * @singleton Only one instance of each register is created per build, but there can be more than one in different build modules
3398
3409
  * @public exported from `@promptbook/core`
3399
3410
  */
3400
3411
  const $scrapersRegister = new $Register('scraper_constructors');
@@ -3562,7 +3573,9 @@ const promptbookFetch = async (urlOrRequest, init) => {
3562
3573
  */
3563
3574
 
3564
3575
  /**
3565
- * @@@
3576
+ * Factory function that creates a handler for processing knowledge sources.
3577
+ * Provides standardized processing of different types of knowledge sources
3578
+ * across various scraper implementations.
3566
3579
  *
3567
3580
  * @public exported from `@promptbook/core`
3568
3581
  */
@@ -3803,9 +3816,12 @@ TODO: [🧊] This is how it can look in future
3803
3816
  */
3804
3817
 
3805
3818
  /**
3806
- * @@@
3819
+ * Prepares tasks by adding knowledge to the prompt and ensuring all necessary parameters are included.
3807
3820
  *
3808
- * @public exported from `@promptbook/core`
3821
+ * @param tasks Sequence of tasks that are chained together to form a pipeline
3822
+ * @returns A promise that resolves to the prepared tasks.
3823
+ *
3824
+ * @private internal utility of `preparePipeline`
3809
3825
  */
3810
3826
  async function prepareTasks(pipeline, tools, options) {
3811
3827
  const { maxParallelCount = DEFAULT_MAX_PARALLEL_COUNT } = options;
@@ -4343,6 +4359,15 @@ const CsvFormatParser = {
4343
4359
  mappedData.push(mappedRow);
4344
4360
  if (onProgress) {
4345
4361
  // Note: Report the CSV with all rows mapped so far
4362
+ /*
4363
+ !!!!
4364
+ // Report progress with updated value
4365
+ const progressData = mappedData.map((row, i) =>
4366
+ i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
4367
+ );
4368
+
4369
+
4370
+ */
4346
4371
  await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
4347
4372
  }
4348
4373
  }
@@ -4559,7 +4584,7 @@ function mapAvailableToExpectedParameters(options) {
4559
4584
  else if (!availableParametersNames.has(parameterName) && expectedParameterNames.has(parameterName)) ;
4560
4585
  }
4561
4586
  if (expectedParameterNames.size === 0) {
4562
- // Note: [👨‍👨‍👧] Now we can freeze `mappedParameters` to prevent @@@
4587
+ // Note: [👨‍👨‍👧] Now we can freeze `mappedParameters` to prevent accidental modifications after mapping
4563
4588
  Object.freeze(mappedParameters);
4564
4589
  return mappedParameters;
4565
4590
  }
@@ -4590,7 +4615,7 @@ function mapAvailableToExpectedParameters(options) {
4590
4615
  for (let i = 0; i < expectedParameterNames.size; i++) {
4591
4616
  mappedParameters[expectedParameterNamesArray[i]] = availableParameters[availableParametersNamesArray[i]];
4592
4617
  }
4593
- // Note: [👨‍👨‍👧] Now we can freeze `mappedParameters` to prevent @@@
4618
+ // Note: [👨‍👨‍👧] Now we can freeze `mappedParameters` to prevent accidental modifications after mapping
4594
4619
  Object.freeze(mappedParameters);
4595
4620
  return mappedParameters;
4596
4621
  }
@@ -5343,15 +5368,14 @@ async function executeFormatSubvalues(options) {
5343
5368
  const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
5344
5369
  ${error.message}
5345
5370
 
5346
- This is error in FOREACH command when mapping data
5371
+ This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
5347
5372
  You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command
5348
5373
 
5349
5374
  ${block(pipelineIdentification)}
5350
- Subparameter index: ${index}
5351
5375
  `));
5352
5376
  if (length > BIG_DATASET_TRESHOLD) {
5353
5377
  console.error(highLevelError);
5354
- return '~';
5378
+ return FAILED_VALUE_PLACEHOLDER;
5355
5379
  }
5356
5380
  throw highLevelError;
5357
5381
  }
@@ -5375,14 +5399,13 @@ async function executeFormatSubvalues(options) {
5375
5399
  catch (error) {
5376
5400
  if (length > BIG_DATASET_TRESHOLD) {
5377
5401
  console.error(spaceTrim$1((block) => `
5378
- Error in FOREACH command:
5402
+ ${error.message}
5379
5403
 
5380
- ${block(pipelineIdentification)}
5404
+ This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
5381
5405
 
5382
5406
  ${block(pipelineIdentification)}
5383
- Subparameter index: ${index}
5384
5407
  `));
5385
- return '~';
5408
+ return FAILED_VALUE_PLACEHOLDER;
5386
5409
  }
5387
5410
  throw error;
5388
5411
  }
@@ -6522,7 +6545,8 @@ class LegacyDocumentScraper {
6522
6545
  */
6523
6546
 
6524
6547
  /**
6525
- * @@@
6548
+ * Creates a scraper for legacy document formats (.doc, .rtf, etc).
6549
+ * Uses LibreOffice for conversion to extract content from older document formats.
6526
6550
  *
6527
6551
  * @public exported from `@promptbook/legacy-documents`
6528
6552
  */