@promptbook/utils 0.71.0-0 → 0.71.0-13
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/README.md +10 -0
- package/esm/index.es.js +68 -73
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/browser.index.d.ts +3 -1
- package/esm/typings/src/_packages/cli.index.d.ts +20 -0
- package/esm/typings/src/_packages/core.index.d.ts +36 -14
- package/esm/typings/src/_packages/documents.index.d.ts +8 -0
- package/esm/typings/src/_packages/legacy-documents.index.d.ts +8 -0
- package/esm/typings/src/_packages/markdown-utils.index.d.ts +6 -0
- package/esm/typings/src/_packages/node.index.d.ts +14 -6
- package/esm/typings/src/_packages/pdf.index.d.ts +8 -0
- package/esm/typings/src/_packages/types.index.d.ts +41 -25
- package/esm/typings/src/_packages/website-crawler.index.d.ts +8 -0
- package/esm/typings/src/cli/cli-commands/about.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +13 -0
- package/esm/typings/src/cli/main.d.ts +1 -1
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +11 -6
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +5 -1
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/KNOWLEDGE/utils/sourceContentToName.d.ts +11 -0
- package/esm/typings/src/commands/KNOWLEDGE/utils/sourceContentToName.test.d.ts +4 -0
- package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/TEMPLATE/templateCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/URL/urlCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
- package/esm/typings/src/config.d.ts +16 -0
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +4 -15
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -1
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +5 -5
- package/esm/typings/src/{knowledge/dialogs → dialogs}/callback/CallbackInterfaceTools.d.ts +2 -2
- package/esm/typings/src/{knowledge/dialogs → dialogs}/callback/CallbackInterfaceToolsOptions.d.ts +3 -3
- package/esm/typings/src/{knowledge/dialogs → dialogs}/simple-prompt/SimplePromptInterfaceTools.d.ts +5 -5
- package/esm/typings/src/errors/AbstractFormatError.d.ts +11 -0
- package/esm/typings/src/errors/KnowledgeScrapeError.d.ts +9 -0
- package/esm/typings/src/errors/MissingToolsError.d.ts +9 -0
- package/esm/typings/src/execution/{CommonExecutionToolsOptions.d.ts → CommonToolsOptions.d.ts} +1 -1
- package/esm/typings/src/execution/ExecutionTools.d.ts +20 -8
- package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -0
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +5 -2
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +2 -13
- package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +3 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -2
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +4 -6
- package/esm/typings/src/execution/createPipelineExecutor/{30-executeFormatCells.d.ts → 30-executeFormatSubvalues.d.ts} +2 -6
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -6
- package/esm/typings/src/execution/embeddingVectorToString.d.ts +1 -1
- package/esm/typings/src/execution/translation/automatic-translate/translateMessages.d.ts +3 -0
- package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +13 -0
- package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -0
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +2 -1
- package/esm/typings/src/formats/csv/CsvFormatError.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/{$llmToolsMetadataRegister.d.ts → register/$llmToolsMetadataRegister.d.ts} +4 -1
- package/esm/typings/src/llm-providers/_common/{$llmToolsRegister.d.ts → register/$llmToolsRegister.d.ts} +5 -2
- package/esm/typings/src/llm-providers/_common/{createLlmToolsFromConfigurationFromEnv.d.ts → register/$provideLlmToolsConfigurationFromEnv.d.ts} +3 -3
- package/esm/typings/src/llm-providers/_common/{getLlmToolsForCli.d.ts → register/$provideLlmToolsForCli.d.ts} +4 -3
- package/esm/typings/src/llm-providers/_common/{getLlmToolsForTestingAndScriptsAndPlayground.d.ts → register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts} +4 -3
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +27 -0
- package/esm/typings/src/llm-providers/_common/{$registeredLlmToolsMessage.d.ts → register/$registeredLlmToolsMessage.d.ts} +5 -2
- package/esm/typings/src/llm-providers/_common/{LlmToolsConfiguration.d.ts → register/LlmToolsConfiguration.d.ts} +5 -4
- package/esm/typings/src/llm-providers/_common/{LlmToolsMetadata.d.ts → register/LlmToolsMetadata.d.ts} +5 -4
- package/esm/typings/src/llm-providers/_common/{LlmToolsOptions.d.ts → register/LlmToolsOptions.d.ts} +4 -1
- package/esm/typings/src/llm-providers/_common/{createLlmToolsFromConfiguration.d.ts → register/createLlmToolsFromConfiguration.d.ts} +5 -4
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +3 -3
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +4 -3
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +4 -3
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +8 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +4 -3
- package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +4 -3
- package/esm/typings/src/llm-providers/langtail/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/multiple/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +2 -1
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +4 -3
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +4 -3
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +3 -3
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/remote/playground/playground.d.ts +3 -0
- package/esm/typings/src/personas/preparePersona.d.ts +3 -2
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +68 -0
- package/esm/typings/src/prepare/preparePipeline.d.ts +3 -2
- package/esm/typings/src/prepare/prepareTemplates.d.ts +3 -2
- package/esm/typings/src/scrapers/_common/Converter.d.ts +22 -0
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +66 -0
- package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +11 -0
- package/esm/typings/src/{knowledge/prepare-knowledge → scrapers}/_common/prepareKnowledgePieces.d.ts +5 -4
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +12 -0
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +15 -0
- package/esm/typings/src/scrapers/_common/register/$registeredScrapersMessage.d.ts +12 -0
- package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +13 -0
- package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +13 -0
- package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +41 -0
- package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +12 -0
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +33 -0
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.test.d.ts +4 -0
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +13 -0
- package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +43 -0
- package/esm/typings/src/scrapers/document/DocumentScraper.test.d.ts +4 -0
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/document/playground/document-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/document/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +43 -0
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.test.d.ts +4 -0
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +29 -0
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/markdown/playground/markdown-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +40 -0
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/pdf/playground/pdf-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +47 -0
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +20 -0
- package/esm/typings/src/scrapers/website/playground/website-scraper-playground.d.ts +5 -0
- package/esm/typings/src/scrapers/website/register-constructor.d.ts +13 -0
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +24 -0
- package/esm/typings/src/scrapers/website/utils/markdownConverter.d.ts +12 -0
- package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +2 -2
- package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +2 -2
- package/esm/typings/src/storage/{files-storage/FilesStorage.d.ts → file-cache-storage/FileCacheStorage.d.ts} +4 -4
- package/esm/typings/src/storage/file-cache-storage/FileCacheStorageOptions.d.ts +10 -0
- package/esm/typings/src/storage/{files-storage → file-cache-storage}/utils/nameToSubfolderPath.d.ts +1 -1
- package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
- package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +1 -1
- package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +1 -1
- package/esm/typings/src/storage/{utils → memory/utils}/PrefixStorage.d.ts +1 -1
- package/esm/typings/src/storage/{utils → memory/utils}/makePromptbookStorageFromWebStorage.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +2 -2
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +0 -3
- package/esm/typings/src/types/execution-report/executionReportJsonToString.d.ts +2 -1
- package/esm/typings/src/types/typeAliases.d.ts +16 -12
- package/esm/typings/src/utils/$Register.d.ts +19 -6
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +14 -0
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +17 -0
- package/esm/typings/src/utils/execCommand/IExecCommandOptions.d.ts +23 -0
- package/esm/typings/src/utils/execCommand/execCommand.test.d.ts +1 -0
- package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.d.ts +10 -0
- package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.test.d.ts +1 -0
- package/esm/typings/src/utils/files/$isDirectoryExisting.d.ts +3 -3
- package/esm/typings/src/utils/files/$isFileExisting.d.ts +3 -3
- package/esm/typings/src/utils/files/$listAllFiles.d.ts +5 -4
- package/esm/typings/src/utils/files/extensionToMimeType.d.ts +8 -0
- package/esm/typings/src/utils/files/extensionToMimeType.test.d.ts +1 -0
- package/esm/typings/src/utils/files/getFileExtension.d.ts +8 -0
- package/esm/typings/src/utils/files/getFileExtension.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -2
- package/package.json +1 -1
- package/umd/index.umd.js +71 -77
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +0 -37
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/playground/markdown-knowledge-playground.d.ts +0 -2
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +0 -14
- package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +0 -15
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +0 -25
- package/esm/typings/src/prepare/PrepareOptions.d.ts +0 -22
- package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +0 -10
- /package/esm/typings/src/{knowledge/dialogs → dialogs}/user-interface-execution-tools.test.d.ts +0 -0
- /package/esm/typings/src/{knowledge/prepare-knowledge → scrapers}/_common/prepareKnowledgePieces.test.d.ts +0 -0
- /package/esm/typings/src/{knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts → scrapers/markdown/MarkdownScraper.test.d.ts} +0 -0
- /package/esm/typings/src/{knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts → scrapers/website/WebsiteScraper.test.d.ts} +0 -0
- /package/esm/typings/src/{storage/files-storage/utils/nameToSubfolderPath.test.d.ts → scrapers/website/utils/markdownConverter.test.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { string_filename } from '../../types/typeAliases';
|
|
2
2
|
/**
|
|
3
3
|
* Checks if the file exists
|
|
4
4
|
*
|
|
@@ -6,9 +6,9 @@ import type { string_file_path } from '../../types/typeAliases';
|
|
|
6
6
|
*
|
|
7
7
|
* @private within the repository
|
|
8
8
|
*/
|
|
9
|
-
export declare function $isFileExisting(
|
|
9
|
+
export declare function $isFileExisting(filename: string_filename): Promise<boolean>;
|
|
10
10
|
/**
|
|
11
|
-
* Note: [🟢]
|
|
11
|
+
* Note: [🟢 !!!!!! After fix makeKnowledgeSourceHandler] Code in this file should never be published outside of `@promptbook/node` and `@promptbook/cli`
|
|
12
12
|
* TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
|
|
13
13
|
* TODO: [🖇] What about symlinks?
|
|
14
14
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { string_dirname } from '../../types/typeAliases';
|
|
2
|
+
import type { string_filename } from '../../types/typeAliases';
|
|
3
3
|
/**
|
|
4
4
|
* Reads all files in the directory
|
|
5
5
|
*
|
|
@@ -10,8 +10,9 @@ import type { string_folder_path } from '../../types/typeAliases';
|
|
|
10
10
|
* @returns List of all files in the directory
|
|
11
11
|
* @private internal function of `createCollectionFromDirectory`
|
|
12
12
|
*/
|
|
13
|
-
export declare function $listAllFiles(path:
|
|
13
|
+
export declare function $listAllFiles(path: string_dirname, isRecursive: boolean): Promise<Array<string_filename>>;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* TODO: [😶] Unite floder listing
|
|
16
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
16
17
|
* TODO: [🖇] What about symlinks?
|
|
17
18
|
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { string_file_extension } from '../../types/typeAliases';
|
|
2
|
+
import type { string_mime_type } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Convert file extension to mime type
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function extensionToMimeType(value: string_file_extension): string_mime_type;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { string_filename } from '../../types/typeAliases';
|
|
2
|
+
import type { string_mime_type } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Get the file extension from a file name
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function getFileExtension(value: string_filename): string_mime_type | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { string_filename } from '../../../types/typeAliases';
|
|
2
2
|
import type { really_unknown } from '../../organization/really_unknown';
|
|
3
3
|
/**
|
|
4
4
|
* Tests if given string is valid URL.
|
|
@@ -6,4 +6,4 @@ import type { really_unknown } from '../../organization/really_unknown';
|
|
|
6
6
|
* Note: This does not check if the file exists only if the path is valid
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
|
-
export declare function isValidFilePath(
|
|
9
|
+
export declare function isValidFilePath(filename: really_unknown): filename is string_filename;
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-utils"] = {}, global.spaceTrim));
|
|
5
|
-
})(this, (function (exports, spaceTrim) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('path')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'path'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-utils"] = {}, global.spaceTrim, global.path));
|
|
5
|
+
})(this, (function (exports, spaceTrim, path) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
/**
|
|
13
13
|
* The version of the Promptbook library
|
|
14
14
|
*/
|
|
15
|
-
var PROMPTBOOK_VERSION = '0.
|
|
16
|
-
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
15
|
+
var PROMPTBOOK_VERSION = '0.71.0-12';
|
|
16
|
+
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
17
17
|
|
|
18
18
|
/*! *****************************************************************************
|
|
19
19
|
Copyright (c) Microsoft Corporation.
|
|
@@ -214,6 +214,35 @@
|
|
|
214
214
|
* TODO: [🌺] Use some intermediate util splitWords
|
|
215
215
|
*/
|
|
216
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Tests if given string is valid URL.
|
|
219
|
+
*
|
|
220
|
+
* Note: Dataurl are considered perfectly valid.
|
|
221
|
+
* Note: There are two simmilar functions:
|
|
222
|
+
* - `isValidUrl` which tests any URL
|
|
223
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
224
|
+
*
|
|
225
|
+
* @public exported from `@promptbook/utils`
|
|
226
|
+
*/
|
|
227
|
+
function isValidUrl(url) {
|
|
228
|
+
if (typeof url !== 'string') {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
if (url.startsWith('blob:')) {
|
|
233
|
+
url = url.replace(/^blob:/, '');
|
|
234
|
+
}
|
|
235
|
+
var urlObject = new URL(url /* because fail is handled */);
|
|
236
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
217
246
|
var defaultDiacriticsRemovalMap = [
|
|
218
247
|
{
|
|
219
248
|
base: 'A',
|
|
@@ -506,10 +535,6 @@
|
|
|
506
535
|
charType = 'NUMBER';
|
|
507
536
|
normalizedChar = char;
|
|
508
537
|
}
|
|
509
|
-
else if (/^\/$/.test(char)) {
|
|
510
|
-
charType = 'SLASH';
|
|
511
|
-
normalizedChar = char;
|
|
512
|
-
}
|
|
513
538
|
else {
|
|
514
539
|
charType = 'OTHER';
|
|
515
540
|
normalizedChar = '-';
|
|
@@ -554,6 +579,32 @@
|
|
|
554
579
|
return text;
|
|
555
580
|
}
|
|
556
581
|
|
|
582
|
+
/**
|
|
583
|
+
* Tests if given string is valid URL.
|
|
584
|
+
*
|
|
585
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
586
|
+
* @public exported from `@promptbook/utils`
|
|
587
|
+
*/
|
|
588
|
+
function isValidFilePath(filename) {
|
|
589
|
+
if (typeof filename !== 'string') {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
var filenameSlashes = filename.split('\\').join('/');
|
|
593
|
+
// Absolute Unix path: /hello.txt
|
|
594
|
+
if (/^(\/)/i.test(filenameSlashes)) {
|
|
595
|
+
return true;
|
|
596
|
+
}
|
|
597
|
+
// Absolute Windows path: /hello.txt
|
|
598
|
+
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
// Relative path: ./hello.txt
|
|
602
|
+
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
603
|
+
return true;
|
|
604
|
+
}
|
|
605
|
+
return false;
|
|
606
|
+
}
|
|
607
|
+
|
|
557
608
|
/**
|
|
558
609
|
* @@@
|
|
559
610
|
*
|
|
@@ -563,14 +614,15 @@
|
|
|
563
614
|
* @public exported from `@promptbook/utils`
|
|
564
615
|
*/
|
|
565
616
|
function titleToName(value) {
|
|
566
|
-
if (
|
|
567
|
-
|
|
568
|
-
|
|
617
|
+
if (isValidUrl(value)) {
|
|
618
|
+
value = value.replace(/^https?:\/\//, '');
|
|
619
|
+
value = value.replace(/\.html$/, '');
|
|
569
620
|
}
|
|
570
|
-
if (
|
|
571
|
-
|
|
572
|
-
|
|
621
|
+
else if (isValidFilePath(value)) {
|
|
622
|
+
value = path.basename(value);
|
|
623
|
+
// Note: Keeping extension in the name
|
|
573
624
|
}
|
|
625
|
+
value = value.split('/').join('-');
|
|
574
626
|
value = removeEmojis(value);
|
|
575
627
|
value = normalizeToKebabCase(value);
|
|
576
628
|
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
@@ -794,7 +846,7 @@
|
|
|
794
846
|
// Note: [🍭] Fixing dependent subparameterName from FOREACH command
|
|
795
847
|
if (foreach !== undefined) {
|
|
796
848
|
try {
|
|
797
|
-
for (var _l = __values(foreach.
|
|
849
|
+
for (var _l = __values(foreach.inputSubparameterNames), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
798
850
|
var subparameterName = _m.value;
|
|
799
851
|
if (parameterNames.has(subparameterName)) {
|
|
800
852
|
parameterNames.delete(subparameterName);
|
|
@@ -1078,6 +1130,7 @@
|
|
|
1078
1130
|
* @param options - Options for the function
|
|
1079
1131
|
* @param callbackfunction - Function to call for each item
|
|
1080
1132
|
* @public exported from `@promptbook/utils`
|
|
1133
|
+
* @deprecated [🪂] Use queues instead
|
|
1081
1134
|
*/
|
|
1082
1135
|
function forEachAsync(array, options, callbackfunction) {
|
|
1083
1136
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1347,10 +1400,6 @@
|
|
|
1347
1400
|
charType = 'NUMBER';
|
|
1348
1401
|
normalizedChar = char;
|
|
1349
1402
|
}
|
|
1350
|
-
else if (/^\/$/.test(char)) {
|
|
1351
|
-
charType = 'SLASH';
|
|
1352
|
-
normalizedChar = char;
|
|
1353
|
-
}
|
|
1354
1403
|
else {
|
|
1355
1404
|
charType = 'OTHER';
|
|
1356
1405
|
normalizedChar = '_';
|
|
@@ -2285,32 +2334,6 @@
|
|
|
2285
2334
|
return /^.+@.+\..+$/.test(email);
|
|
2286
2335
|
}
|
|
2287
2336
|
|
|
2288
|
-
/**
|
|
2289
|
-
* Tests if given string is valid URL.
|
|
2290
|
-
*
|
|
2291
|
-
* Note: This does not check if the file exists only if the path is valid
|
|
2292
|
-
* @public exported from `@promptbook/utils`
|
|
2293
|
-
*/
|
|
2294
|
-
function isValidFilePath(filePath) {
|
|
2295
|
-
if (typeof filePath !== 'string') {
|
|
2296
|
-
return false;
|
|
2297
|
-
}
|
|
2298
|
-
var filePathSlashes = filePath.split('\\').join('/');
|
|
2299
|
-
// Absolute Unix path: /hello.txt
|
|
2300
|
-
if (/^(\/)/i.test(filePathSlashes)) {
|
|
2301
|
-
return true;
|
|
2302
|
-
}
|
|
2303
|
-
// Absolute Windows path: /hello.txt
|
|
2304
|
-
if (/^([A-Z]{1,2}:\/?)\//i.test(filePathSlashes)) {
|
|
2305
|
-
return true;
|
|
2306
|
-
}
|
|
2307
|
-
// Relative path: ./hello.txt
|
|
2308
|
-
if (/^(\.\.?\/)+/i.test(filePathSlashes)) {
|
|
2309
|
-
return true;
|
|
2310
|
-
}
|
|
2311
|
-
return false;
|
|
2312
|
-
}
|
|
2313
|
-
|
|
2314
2337
|
/**
|
|
2315
2338
|
* @@@
|
|
2316
2339
|
*
|
|
@@ -2363,7 +2386,7 @@
|
|
|
2363
2386
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
2364
2387
|
return false;
|
|
2365
2388
|
}
|
|
2366
|
-
// <- TODO:[main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
2389
|
+
// <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
2367
2390
|
return true;
|
|
2368
2391
|
}
|
|
2369
2392
|
|
|
@@ -2418,35 +2441,6 @@
|
|
|
2418
2441
|
return isHostnameOnPrivateNetwork(url.hostname);
|
|
2419
2442
|
}
|
|
2420
2443
|
|
|
2421
|
-
/**
|
|
2422
|
-
* Tests if given string is valid URL.
|
|
2423
|
-
*
|
|
2424
|
-
* Note: Dataurl are considered perfectly valid.
|
|
2425
|
-
* Note: There are two simmilar functions:
|
|
2426
|
-
* - `isValidUrl` which tests any URL
|
|
2427
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
2428
|
-
*
|
|
2429
|
-
* @public exported from `@promptbook/utils`
|
|
2430
|
-
*/
|
|
2431
|
-
function isValidUrl(url) {
|
|
2432
|
-
if (typeof url !== 'string') {
|
|
2433
|
-
return false;
|
|
2434
|
-
}
|
|
2435
|
-
try {
|
|
2436
|
-
if (url.startsWith('blob:')) {
|
|
2437
|
-
url = url.replace(/^blob:/, '');
|
|
2438
|
-
}
|
|
2439
|
-
var urlObject = new URL(url /* because fail is handled */);
|
|
2440
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
2441
|
-
return false;
|
|
2442
|
-
}
|
|
2443
|
-
return true;
|
|
2444
|
-
}
|
|
2445
|
-
catch (error) {
|
|
2446
|
-
return false;
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
|
|
2450
2444
|
/**
|
|
2451
2445
|
* Tests if given string is valid pipeline URL URL.
|
|
2452
2446
|
*
|