@promptbook/markdown-utils 0.92.0-24 → 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.
- package/esm/index.es.js +41 -36
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +0 -2
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +36 -28
- package/esm/typings/src/constants.d.ts +2 -2
- package/esm/typings/src/errors/0-BoilerplateError.d.ts +2 -2
- package/esm/typings/src/execution/CommonToolsOptions.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/register/$llmToolsMetadataRegister.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/register/$llmToolsRegister.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +4 -4
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +5 -5
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +5 -3
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +5 -5
- package/esm/typings/src/other/templates/getBookTemplates.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +3 -3
- package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineInterface/getPipelineInterface.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineInterface/isPipelineImplementingInterface.d.ts +5 -4
- package/esm/typings/src/pipeline/PipelineInterface/isPipelineInterfacesEqual.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineJson/CommonTaskJson.d.ts +9 -6
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineString.d.ts +3 -1
- package/esm/typings/src/pipeline/book-notation.d.ts +2 -2
- package/esm/typings/src/prepare/prepareTasks.d.ts +7 -4
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +2 -1
- package/esm/typings/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +3 -3
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/Converter.d.ts +3 -1
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +4 -3
- package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +4 -2
- package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -1
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +6 -3
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +3 -5
- package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +3 -2
- package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +8 -5
- package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +2 -1
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +6 -5
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +3 -1
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +2 -1
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +4 -1
- package/esm/typings/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +2 -1
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -4
- package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +5 -1
- package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +12 -5
- package/esm/typings/src/storage/file-cache-storage/FileCacheStorageOptions.d.ts +4 -2
- package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +2 -1
- package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.d.ts +2 -1
- package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +2 -1
- package/esm/typings/src/types/ModelVariant.d.ts +5 -5
- package/esm/typings/src/types/typeAliases.d.ts +8 -6
- package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +2 -2
- package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +4 -1
- package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +2 -1
- package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/normalization/nameToUriPart.d.ts +4 -4
- package/esm/typings/src/utils/normalization/nameToUriParts.d.ts +4 -4
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -3
- package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +3 -3
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +4 -4
- package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +3 -3
- package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +3 -3
- package/esm/typings/src/utils/normalization/searchKeywords.d.ts +4 -1
- package/esm/typings/src/utils/normalization/titleToName.d.ts +4 -4
- package/esm/typings/src/utils/organization/empty_object.d.ts +2 -2
- package/esm/typings/src/utils/organization/just_empty_object.d.ts +4 -4
- package/esm/typings/src/version.d.ts +2 -1
- package/package.json +1 -1
- package/umd/index.umd.js +41 -36
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -25,7 +25,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-25';
|
|
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
|
|
@@ -1118,13 +1118,13 @@ const ORDER_OF_PIPELINE_JSON = [
|
|
|
1118
1118
|
*/
|
|
1119
1119
|
const REPLACING_NONCE = 'ptbkauk42kV2dzao34faw7FudQUHYPtW';
|
|
1120
1120
|
/**
|
|
1121
|
-
*
|
|
1121
|
+
* Placeholder value indicating a parameter is missing its value.
|
|
1122
1122
|
*
|
|
1123
1123
|
* @private within the repository
|
|
1124
1124
|
*/
|
|
1125
1125
|
const RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
1126
1126
|
/**
|
|
1127
|
-
*
|
|
1127
|
+
* Placeholder value indicating a parameter is restricted and cannot be used directly.
|
|
1128
1128
|
*
|
|
1129
1129
|
* @private within the repository
|
|
1130
1130
|
*/
|
|
@@ -1787,8 +1787,8 @@ class PipelineExecutionError extends Error {
|
|
|
1787
1787
|
* @public exported from `@promptbook/core`
|
|
1788
1788
|
*/
|
|
1789
1789
|
function isPipelinePrepared(pipeline) {
|
|
1790
|
-
// Note: Ignoring `pipeline.preparations`
|
|
1791
|
-
// Note: Ignoring `pipeline.knowledgePieces`
|
|
1790
|
+
// Note: Ignoring `pipeline.preparations`
|
|
1791
|
+
// Note: Ignoring `pipeline.knowledgePieces`
|
|
1792
1792
|
if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
|
|
1793
1793
|
// TODO: !!! Comment this out
|
|
1794
1794
|
console.log('Pipeline is not prepared because title is undefined or empty', pipeline);
|
|
@@ -2798,10 +2798,10 @@ function $getGlobalScope() {
|
|
|
2798
2798
|
}
|
|
2799
2799
|
|
|
2800
2800
|
/**
|
|
2801
|
-
*
|
|
2801
|
+
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
2802
2802
|
*
|
|
2803
|
-
* @param text
|
|
2804
|
-
* @returns
|
|
2803
|
+
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
2804
|
+
* @returns The normalized text in SCREAMING_CASE format.
|
|
2805
2805
|
* @example 'HELLO_WORLD'
|
|
2806
2806
|
* @example 'I_LOVE_PROMPTBOOK'
|
|
2807
2807
|
* @public exported from `@promptbook/utils`
|
|
@@ -2853,10 +2853,10 @@ function normalizeTo_SCREAMING_CASE(text) {
|
|
|
2853
2853
|
*/
|
|
2854
2854
|
|
|
2855
2855
|
/**
|
|
2856
|
-
*
|
|
2856
|
+
* Normalizes a text string to snake_case format.
|
|
2857
2857
|
*
|
|
2858
|
-
* @param text
|
|
2859
|
-
* @returns
|
|
2858
|
+
* @param text The text string to be converted to snake_case format.
|
|
2859
|
+
* @returns The normalized text in snake_case format.
|
|
2860
2860
|
* @example 'hello_world'
|
|
2861
2861
|
* @example 'i_love_promptbook'
|
|
2862
2862
|
* @public exported from `@promptbook/utils`
|
|
@@ -2926,10 +2926,11 @@ const $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
|
2926
2926
|
*/
|
|
2927
2927
|
|
|
2928
2928
|
/**
|
|
2929
|
-
*
|
|
2929
|
+
* Registry for all available scrapers in the system.
|
|
2930
|
+
* Central point for registering and accessing different types of content scrapers.
|
|
2930
2931
|
*
|
|
2931
2932
|
* Note: `$` is used to indicate that this interacts with the global scope
|
|
2932
|
-
* @singleton Only one instance of each register is created per build, but
|
|
2933
|
+
* @singleton Only one instance of each register is created per build, but there can be more than one in different build modules
|
|
2933
2934
|
* @public exported from `@promptbook/core`
|
|
2934
2935
|
*/
|
|
2935
2936
|
const $scrapersRegister = new $Register('scraper_constructors');
|
|
@@ -3269,10 +3270,10 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
3269
3270
|
*/
|
|
3270
3271
|
|
|
3271
3272
|
/**
|
|
3272
|
-
*
|
|
3273
|
+
* Removes diacritic marks (accents) from characters in a string.
|
|
3273
3274
|
*
|
|
3274
|
-
* @param input
|
|
3275
|
-
* @returns
|
|
3275
|
+
* @param input The string containing diacritics to be normalized.
|
|
3276
|
+
* @returns The string with diacritics removed or normalized.
|
|
3276
3277
|
* @public exported from `@promptbook/utils`
|
|
3277
3278
|
*/
|
|
3278
3279
|
function removeDiacritics(input) {
|
|
@@ -3286,10 +3287,10 @@ function removeDiacritics(input) {
|
|
|
3286
3287
|
*/
|
|
3287
3288
|
|
|
3288
3289
|
/**
|
|
3289
|
-
*
|
|
3290
|
+
* Converts a given text to kebab-case format.
|
|
3290
3291
|
*
|
|
3291
|
-
* @param text
|
|
3292
|
-
* @returns
|
|
3292
|
+
* @param text The text to be converted.
|
|
3293
|
+
* @returns The kebab-case formatted string.
|
|
3293
3294
|
* @example 'hello-world'
|
|
3294
3295
|
* @example 'i-love-promptbook'
|
|
3295
3296
|
* @public exported from `@promptbook/utils`
|
|
@@ -3358,7 +3359,8 @@ function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
|
3358
3359
|
*/
|
|
3359
3360
|
|
|
3360
3361
|
/**
|
|
3361
|
-
*
|
|
3362
|
+
* Converts a name to a properly formatted subfolder path for cache storage.
|
|
3363
|
+
* Handles normalization and path formatting to create consistent cache directory structures.
|
|
3362
3364
|
*
|
|
3363
3365
|
* @private for `FileCacheStorage`
|
|
3364
3366
|
*/
|
|
@@ -3438,11 +3440,11 @@ function removeEmojis(text) {
|
|
|
3438
3440
|
}
|
|
3439
3441
|
|
|
3440
3442
|
/**
|
|
3441
|
-
*
|
|
3443
|
+
* Converts a title string into a normalized name.
|
|
3442
3444
|
*
|
|
3443
|
-
* @param value
|
|
3444
|
-
* @returns
|
|
3445
|
-
* @example
|
|
3445
|
+
* @param value The title string to be converted to a name.
|
|
3446
|
+
* @returns A normalized name derived from the input title.
|
|
3447
|
+
* @example 'Hello World!' -> 'hello-world'
|
|
3446
3448
|
* @public exported from `@promptbook/utils`
|
|
3447
3449
|
*/
|
|
3448
3450
|
function titleToName(value) {
|
|
@@ -3493,7 +3495,9 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
3493
3495
|
*/
|
|
3494
3496
|
|
|
3495
3497
|
/**
|
|
3496
|
-
*
|
|
3498
|
+
* Factory function that creates a handler for processing knowledge sources.
|
|
3499
|
+
* Provides standardized processing of different types of knowledge sources
|
|
3500
|
+
* across various scraper implementations.
|
|
3497
3501
|
*
|
|
3498
3502
|
* @public exported from `@promptbook/core`
|
|
3499
3503
|
*/
|
|
@@ -3734,9 +3738,12 @@ TODO: [🧊] This is how it can look in future
|
|
|
3734
3738
|
*/
|
|
3735
3739
|
|
|
3736
3740
|
/**
|
|
3737
|
-
*
|
|
3741
|
+
* Prepares tasks by adding knowledge to the prompt and ensuring all necessary parameters are included.
|
|
3738
3742
|
*
|
|
3739
|
-
* @
|
|
3743
|
+
* @param tasks Sequence of tasks that are chained together to form a pipeline
|
|
3744
|
+
* @returns A promise that resolves to the prepared tasks.
|
|
3745
|
+
*
|
|
3746
|
+
* @private internal utility of `preparePipeline`
|
|
3740
3747
|
*/
|
|
3741
3748
|
async function prepareTasks(pipeline, tools, options) {
|
|
3742
3749
|
const { maxParallelCount = DEFAULT_MAX_PARALLEL_COUNT } = options;
|
|
@@ -4499,7 +4506,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
4499
4506
|
else if (!availableParametersNames.has(parameterName) && expectedParameterNames.has(parameterName)) ;
|
|
4500
4507
|
}
|
|
4501
4508
|
if (expectedParameterNames.size === 0) {
|
|
4502
|
-
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent
|
|
4509
|
+
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent accidental modifications after mapping
|
|
4503
4510
|
Object.freeze(mappedParameters);
|
|
4504
4511
|
return mappedParameters;
|
|
4505
4512
|
}
|
|
@@ -4530,7 +4537,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
4530
4537
|
for (let i = 0; i < expectedParameterNames.size; i++) {
|
|
4531
4538
|
mappedParameters[expectedParameterNamesArray[i]] = availableParameters[availableParametersNamesArray[i]];
|
|
4532
4539
|
}
|
|
4533
|
-
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent
|
|
4540
|
+
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent accidental modifications after mapping
|
|
4534
4541
|
Object.freeze(mappedParameters);
|
|
4535
4542
|
return mappedParameters;
|
|
4536
4543
|
}
|
|
@@ -5181,11 +5188,10 @@ async function executeFormatSubvalues(options) {
|
|
|
5181
5188
|
const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
|
|
5182
5189
|
${error.message}
|
|
5183
5190
|
|
|
5184
|
-
This is error in FOREACH command when mapping data
|
|
5191
|
+
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
5185
5192
|
You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command
|
|
5186
5193
|
|
|
5187
5194
|
${block(pipelineIdentification)}
|
|
5188
|
-
Subparameter index: ${index}
|
|
5189
5195
|
`));
|
|
5190
5196
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
5191
5197
|
console.error(highLevelError);
|
|
@@ -5213,12 +5219,11 @@ async function executeFormatSubvalues(options) {
|
|
|
5213
5219
|
catch (error) {
|
|
5214
5220
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
5215
5221
|
console.error(spaceTrim((block) => `
|
|
5216
|
-
|
|
5222
|
+
${error.message}
|
|
5217
5223
|
|
|
5218
|
-
${
|
|
5224
|
+
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
5219
5225
|
|
|
5220
5226
|
${block(pipelineIdentification)}
|
|
5221
|
-
Subparameter index: ${index}
|
|
5222
5227
|
`));
|
|
5223
5228
|
return FAILED_VALUE_PLACEHOLDER;
|
|
5224
5229
|
}
|
|
@@ -6057,7 +6062,7 @@ class MarkdownScraper {
|
|
|
6057
6062
|
*/
|
|
6058
6063
|
|
|
6059
6064
|
/**
|
|
6060
|
-
*
|
|
6065
|
+
* Creates a scraper for markdown content.
|
|
6061
6066
|
*
|
|
6062
6067
|
* @public exported from `@promptbook/markdown-utils`
|
|
6063
6068
|
*/
|
|
@@ -6212,7 +6217,7 @@ function escapeMarkdownBlock(value) {
|
|
|
6212
6217
|
* Note: It can not work with html syntax and comments
|
|
6213
6218
|
*
|
|
6214
6219
|
* @param markdown any valid markdown
|
|
6215
|
-
* @returns
|
|
6220
|
+
* @returns An array of strings, each representing an individual list item found in the markdown
|
|
6216
6221
|
* @public exported from `@promptbook/markdown-utils`
|
|
6217
6222
|
*/
|
|
6218
6223
|
function extractAllListItemsFromMarkdown(markdown) {
|