@promptbook/node 0.71.0-13 → 0.71.0-15
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 +92 -82
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/node.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +2 -2
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -1
- package/esm/typings/src/execution/ExecutionTools.d.ts +12 -4
- package/esm/typings/src/execution/FilesystemTools.d.ts +9 -0
- package/esm/typings/src/execution/translation/automatic-translate/translateMessages.d.ts +1 -0
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +0 -1
- package/esm/typings/src/prepare/preparePipeline.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +11 -0
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +1 -0
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +2 -4
- package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +1 -1
- package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +3 -1
- package/esm/typings/src/utils/files/{$isDirectoryExisting.d.ts → isDirectoryExisting.d.ts} +3 -4
- package/esm/typings/src/utils/files/isFileExisting.d.ts +13 -0
- package/esm/typings/src/utils/files/{$listAllFiles.d.ts → listAllFiles.d.ts} +3 -4
- package/package.json +2 -2
- package/umd/index.umd.js +91 -80
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/utils/files/$isFileExisting.d.ts +0 -14
- /package/esm/typings/src/utils/files/{$isDirectoryExisting.test.d.ts → isDirectoryExisting.test.d.ts} +0 -0
- /package/esm/typings/src/utils/files/{$isFileExisting.test.d.ts → isFileExisting.test.d.ts} +0 -0
- /package/esm/typings/src/utils/files/{$listAllFiles.test.d.ts → listAllFiles.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
|
-
import { stat, access, constants,
|
|
2
|
+
import { readFile, stat, access, constants, readdir, writeFile, mkdir, unlink } from 'fs/promises';
|
|
3
3
|
import { join, basename, dirname } from 'path';
|
|
4
4
|
import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
5
5
|
import { format } from 'prettier';
|
|
@@ -17,7 +17,7 @@ import { spawn } from 'child_process';
|
|
|
17
17
|
/**
|
|
18
18
|
* The version of the Promptbook library
|
|
19
19
|
*/
|
|
20
|
-
var PROMPTBOOK_VERSION = '0.71.0-
|
|
20
|
+
var PROMPTBOOK_VERSION = '0.71.0-14';
|
|
21
21
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
22
22
|
|
|
23
23
|
/*! *****************************************************************************
|
|
@@ -4930,39 +4930,45 @@ function sourceContentToName(sourceContent) {
|
|
|
4930
4930
|
*/
|
|
4931
4931
|
|
|
4932
4932
|
/**
|
|
4933
|
-
*
|
|
4933
|
+
* Convert file extension to mime type
|
|
4934
4934
|
*
|
|
4935
|
-
*
|
|
4935
|
+
* @private within the repository
|
|
4936
|
+
*/
|
|
4937
|
+
function extensionToMimeType(value) {
|
|
4938
|
+
return lookup(value) || 'application/octet-stream';
|
|
4939
|
+
}
|
|
4940
|
+
|
|
4941
|
+
/**
|
|
4942
|
+
* Get the file extension from a file name
|
|
4936
4943
|
*
|
|
4937
|
-
* @
|
|
4944
|
+
* @private within the repository
|
|
4938
4945
|
*/
|
|
4939
|
-
|
|
4946
|
+
function getFileExtension(value) {
|
|
4947
|
+
var match = value.match(/\.([0-9a-z]+)(?:[?#]|$)/i);
|
|
4948
|
+
return match ? match[1].toLowerCase() : null;
|
|
4949
|
+
}
|
|
4940
4950
|
|
|
4941
4951
|
/**
|
|
4942
4952
|
* Checks if the file exists
|
|
4943
4953
|
*
|
|
4944
|
-
* Note: `$` is used to indicate that this function is not a pure function - it looks at the filesystem
|
|
4945
|
-
*
|
|
4946
4954
|
* @private within the repository
|
|
4947
4955
|
*/
|
|
4948
|
-
function
|
|
4956
|
+
function isFileExisting(filename, fs) {
|
|
4949
4957
|
return __awaiter(this, void 0, void 0, function () {
|
|
4950
4958
|
var isReadAccessAllowed, isFile;
|
|
4951
4959
|
return __generator(this, function (_a) {
|
|
4952
4960
|
switch (_a.label) {
|
|
4953
|
-
case 0:
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
return [4 /*yield*/, access(filename, constants.R_OK)
|
|
4958
|
-
.then(function () { return true; })
|
|
4959
|
-
.catch(function () { return false; })];
|
|
4961
|
+
case 0: return [4 /*yield*/, fs
|
|
4962
|
+
.access(filename, fs.constants.R_OK)
|
|
4963
|
+
.then(function () { return true; })
|
|
4964
|
+
.catch(function () { return false; })];
|
|
4960
4965
|
case 1:
|
|
4961
4966
|
isReadAccessAllowed = _a.sent();
|
|
4962
4967
|
if (!isReadAccessAllowed) {
|
|
4963
4968
|
return [2 /*return*/, false];
|
|
4964
4969
|
}
|
|
4965
|
-
return [4 /*yield*/,
|
|
4970
|
+
return [4 /*yield*/, fs
|
|
4971
|
+
.stat(filename)
|
|
4966
4972
|
.then(function (fileStat) { return fileStat.isFile(); })
|
|
4967
4973
|
.catch(function () { return false; })];
|
|
4968
4974
|
case 2:
|
|
@@ -4973,30 +4979,11 @@ function $isFileExisting(filename) {
|
|
|
4973
4979
|
});
|
|
4974
4980
|
}
|
|
4975
4981
|
/**
|
|
4976
|
-
* Note: [
|
|
4982
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
4977
4983
|
* TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
|
|
4978
4984
|
* TODO: [🖇] What about symlinks?
|
|
4979
4985
|
*/
|
|
4980
4986
|
|
|
4981
|
-
/**
|
|
4982
|
-
* Convert file extension to mime type
|
|
4983
|
-
*
|
|
4984
|
-
* @private within the repository
|
|
4985
|
-
*/
|
|
4986
|
-
function extensionToMimeType(value) {
|
|
4987
|
-
return lookup(value) || 'application/octet-stream';
|
|
4988
|
-
}
|
|
4989
|
-
|
|
4990
|
-
/**
|
|
4991
|
-
* Get the file extension from a file name
|
|
4992
|
-
*
|
|
4993
|
-
* @private within the repository
|
|
4994
|
-
*/
|
|
4995
|
-
function getFileExtension(value) {
|
|
4996
|
-
var match = value.match(/\.([0-9a-z]+)(?:[?#]|$)/i);
|
|
4997
|
-
return match ? match[1].toLowerCase() : null;
|
|
4998
|
-
}
|
|
4999
|
-
|
|
5000
4987
|
/**
|
|
5001
4988
|
* Tests if given string is valid URL.
|
|
5002
4989
|
*
|
|
@@ -5028,7 +5015,7 @@ function isValidFilePath(filename) {
|
|
|
5028
5015
|
*
|
|
5029
5016
|
* @private for scraper utilities
|
|
5030
5017
|
*/
|
|
5031
|
-
function makeKnowledgeSourceHandler(knowledgeSource, options) {
|
|
5018
|
+
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5032
5019
|
var _a;
|
|
5033
5020
|
return __awaiter(this, void 0, void 0, function () {
|
|
5034
5021
|
var sourceContent, name, _b, _c, rootDirname, _d,
|
|
@@ -5097,8 +5084,9 @@ function makeKnowledgeSourceHandler(knowledgeSource, options) {
|
|
|
5097
5084
|
}];
|
|
5098
5085
|
case 2:
|
|
5099
5086
|
if (!(isValidFilePath(sourceContent) || /\.[a-z]{1,10}$/i.exec(sourceContent))) return [3 /*break*/, 4];
|
|
5100
|
-
if (
|
|
5101
|
-
throw new EnvironmentMismatchError('
|
|
5087
|
+
if (tools.fs === undefined) {
|
|
5088
|
+
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
5089
|
+
// <- TODO: [🧠] What is the best error type here`
|
|
5102
5090
|
}
|
|
5103
5091
|
if (rootDirname === null) {
|
|
5104
5092
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
@@ -5107,7 +5095,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, options) {
|
|
|
5107
5095
|
filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
|
|
5108
5096
|
fileExtension = getFileExtension(filename_1);
|
|
5109
5097
|
mimeType_1 = extensionToMimeType(fileExtension || '');
|
|
5110
|
-
return [4 /*yield*/,
|
|
5098
|
+
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5111
5099
|
case 3:
|
|
5112
5100
|
if (!(_e.sent())) {
|
|
5113
5101
|
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(filename_1), "\n "); }));
|
|
@@ -5123,7 +5111,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, options) {
|
|
|
5123
5111
|
var content;
|
|
5124
5112
|
return __generator(this, function (_a) {
|
|
5125
5113
|
switch (_a.label) {
|
|
5126
|
-
case 0: return [4 /*yield*/, readFile(filename_1)];
|
|
5114
|
+
case 0: return [4 /*yield*/, tools.fs.readFile(filename_1)];
|
|
5127
5115
|
case 1:
|
|
5128
5116
|
content = _a.sent();
|
|
5129
5117
|
return [2 /*return*/, new Blob([
|
|
@@ -5177,9 +5165,6 @@ function makeKnowledgeSourceHandler(knowledgeSource, options) {
|
|
|
5177
5165
|
});
|
|
5178
5166
|
});
|
|
5179
5167
|
}
|
|
5180
|
-
/**
|
|
5181
|
-
* TODO: !!!!!!! Maybe constrain to @promptbook/node bundle
|
|
5182
|
-
*/
|
|
5183
5168
|
|
|
5184
5169
|
/**
|
|
5185
5170
|
* Prepares the knowle
|
|
@@ -5203,7 +5188,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
5203
5188
|
switch (_d.label) {
|
|
5204
5189
|
case 0:
|
|
5205
5190
|
partialPieces = null;
|
|
5206
|
-
return [4 /*yield*/, makeKnowledgeSourceHandler(knowledgeSource, { rootDirname: rootDirname, isVerbose: isVerbose })];
|
|
5191
|
+
return [4 /*yield*/, makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname: rootDirname, isVerbose: isVerbose })];
|
|
5207
5192
|
case 1:
|
|
5208
5193
|
sourceHandler = _d.sent();
|
|
5209
5194
|
_d.label = 2;
|
|
@@ -8204,6 +8189,15 @@ function pipelineStringToJson(pipelineString, tools, options) {
|
|
|
8204
8189
|
* TODO: [🧠] Should be in generated JSON file GENERATOR_WARNING
|
|
8205
8190
|
*/
|
|
8206
8191
|
|
|
8192
|
+
/**
|
|
8193
|
+
* Detects if the code is running in a Node.js environment
|
|
8194
|
+
*
|
|
8195
|
+
* Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
|
|
8196
|
+
*
|
|
8197
|
+
* @public exported from `@promptbook/utils`
|
|
8198
|
+
*/
|
|
8199
|
+
var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
|
|
8200
|
+
|
|
8207
8201
|
/**
|
|
8208
8202
|
* @@@
|
|
8209
8203
|
*
|
|
@@ -8432,7 +8426,29 @@ function $provideLlmToolsFromEnv(options) {
|
|
|
8432
8426
|
* TODO: [🥃] Allow `ptbk make` without llm tools
|
|
8433
8427
|
* TODO: This should be maybe not under `_common` but under `utils`
|
|
8434
8428
|
* TODO: [®] DRY Register logic
|
|
8435
|
-
|
|
8429
|
+
*/
|
|
8430
|
+
|
|
8431
|
+
/**
|
|
8432
|
+
* @@@
|
|
8433
|
+
*
|
|
8434
|
+
* @public exported from `@promptbook/node`
|
|
8435
|
+
*/
|
|
8436
|
+
function $provideFilesystemForNode(options) {
|
|
8437
|
+
if (!$isRunningInNode()) {
|
|
8438
|
+
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8439
|
+
}
|
|
8440
|
+
var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
|
|
8441
|
+
TODO_USE(isVerbose);
|
|
8442
|
+
return {
|
|
8443
|
+
stat: stat,
|
|
8444
|
+
access: access,
|
|
8445
|
+
constants: constants,
|
|
8446
|
+
readFile: readFile,
|
|
8447
|
+
readdir: readdir,
|
|
8448
|
+
};
|
|
8449
|
+
}
|
|
8450
|
+
/**
|
|
8451
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8436
8452
|
*/
|
|
8437
8453
|
|
|
8438
8454
|
/**
|
|
@@ -8947,7 +8963,7 @@ var JavascriptExecutionTools = JavascriptEvalExecutionTools;
|
|
|
8947
8963
|
*/
|
|
8948
8964
|
function $provideExecutionToolsForNode(options) {
|
|
8949
8965
|
return __awaiter(this, void 0, void 0, function () {
|
|
8950
|
-
var llm, tools;
|
|
8966
|
+
var fs, llm, tools;
|
|
8951
8967
|
var _a;
|
|
8952
8968
|
return __generator(this, function (_b) {
|
|
8953
8969
|
switch (_b.label) {
|
|
@@ -8955,11 +8971,13 @@ function $provideExecutionToolsForNode(options) {
|
|
|
8955
8971
|
if (!$isRunningInNode()) {
|
|
8956
8972
|
throw new EnvironmentMismatchError('Function `$getExecutionToolsForNode` works only in Node.js environment');
|
|
8957
8973
|
}
|
|
8974
|
+
fs = $provideFilesystemForNode();
|
|
8958
8975
|
llm = $provideLlmToolsFromEnv(options);
|
|
8959
8976
|
_a = {
|
|
8960
|
-
llm: llm
|
|
8977
|
+
llm: llm,
|
|
8978
|
+
fs: fs
|
|
8961
8979
|
};
|
|
8962
|
-
return [4 /*yield*/, $provideScrapersForNode({ llm: llm }, options)];
|
|
8980
|
+
return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm }, options)];
|
|
8963
8981
|
case 1:
|
|
8964
8982
|
tools = (_a.scrapers = _b.sent(),
|
|
8965
8983
|
_a.script = [new JavascriptExecutionTools(options)],
|
|
@@ -8976,28 +8994,24 @@ function $provideExecutionToolsForNode(options) {
|
|
|
8976
8994
|
/**
|
|
8977
8995
|
* Checks if the directory exists
|
|
8978
8996
|
*
|
|
8979
|
-
* Note: `$` is used to indicate that this function is not a pure function - it looks at the filesystem
|
|
8980
|
-
*
|
|
8981
8997
|
* @private within the repository
|
|
8982
8998
|
*/
|
|
8983
|
-
function
|
|
8999
|
+
function isDirectoryExisting(directoryPath, fs) {
|
|
8984
9000
|
return __awaiter(this, void 0, void 0, function () {
|
|
8985
9001
|
var isReadAccessAllowed, isDirectory;
|
|
8986
9002
|
return __generator(this, function (_a) {
|
|
8987
9003
|
switch (_a.label) {
|
|
8988
|
-
case 0:
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
return [4 /*yield*/, access(directoryPath, constants.R_OK)
|
|
8993
|
-
.then(function () { return true; })
|
|
8994
|
-
.catch(function () { return false; })];
|
|
9004
|
+
case 0: return [4 /*yield*/, fs
|
|
9005
|
+
.access(directoryPath, fs.constants.R_OK)
|
|
9006
|
+
.then(function () { return true; })
|
|
9007
|
+
.catch(function () { return false; })];
|
|
8995
9008
|
case 1:
|
|
8996
9009
|
isReadAccessAllowed = _a.sent();
|
|
8997
9010
|
if (!isReadAccessAllowed) {
|
|
8998
9011
|
return [2 /*return*/, false];
|
|
8999
9012
|
}
|
|
9000
|
-
return [4 /*yield*/,
|
|
9013
|
+
return [4 /*yield*/, fs
|
|
9014
|
+
.stat(directoryPath)
|
|
9001
9015
|
.then(function (fileStat) { return fileStat.isDirectory(); })
|
|
9002
9016
|
.catch(function () { return false; })];
|
|
9003
9017
|
case 2:
|
|
@@ -9008,7 +9022,7 @@ function $isDirectoryExisting(directoryPath) {
|
|
|
9008
9022
|
});
|
|
9009
9023
|
}
|
|
9010
9024
|
/**
|
|
9011
|
-
* Note: [
|
|
9025
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
9012
9026
|
* TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
|
|
9013
9027
|
* TODO: [🧠][📂] "directory" vs "folder"
|
|
9014
9028
|
* TODO: [🖇] What about symlinks?
|
|
@@ -9017,30 +9031,24 @@ function $isDirectoryExisting(directoryPath) {
|
|
|
9017
9031
|
/**
|
|
9018
9032
|
* Reads all files in the directory
|
|
9019
9033
|
*
|
|
9020
|
-
* Note: `$` is used to indicate that this function is not a pure function - it looks at the filesystem
|
|
9021
|
-
*
|
|
9022
9034
|
* @param path
|
|
9023
9035
|
* @param isRecursive
|
|
9024
9036
|
* @returns List of all files in the directory
|
|
9025
9037
|
* @private internal function of `createCollectionFromDirectory`
|
|
9026
9038
|
*/
|
|
9027
|
-
function
|
|
9039
|
+
function listAllFiles(path, isRecursive, fs) {
|
|
9028
9040
|
return __awaiter(this, void 0, void 0, function () {
|
|
9029
9041
|
var dirents, fileNames, _a, _b, dirent, subPath, _c, _d, _e, _f, e_1_1;
|
|
9030
9042
|
var e_1, _g;
|
|
9031
9043
|
return __generator(this, function (_h) {
|
|
9032
9044
|
switch (_h.label) {
|
|
9033
|
-
case 0:
|
|
9034
|
-
if (!$isRunningInNode()) {
|
|
9035
|
-
throw new EnvironmentMismatchError('Function `$listAllFiles` works only in Node environment.js');
|
|
9036
|
-
}
|
|
9037
|
-
return [4 /*yield*/, $isDirectoryExisting(path)];
|
|
9045
|
+
case 0: return [4 /*yield*/, isDirectoryExisting(path, fs)];
|
|
9038
9046
|
case 1:
|
|
9039
9047
|
if (!(_h.sent())) {
|
|
9040
9048
|
throw new Error("Directory \"".concat(path, "\" does not exist or is not readable"));
|
|
9041
9049
|
// <- TODO: Use some custom error class
|
|
9042
9050
|
}
|
|
9043
|
-
return [4 /*yield*/, readdir(path, {
|
|
9051
|
+
return [4 /*yield*/, fs.readdir(path, {
|
|
9044
9052
|
withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
|
|
9045
9053
|
})];
|
|
9046
9054
|
case 2:
|
|
@@ -9064,7 +9072,7 @@ function $listAllFiles(path, isRecursive) {
|
|
|
9064
9072
|
_d = (_c = fileNames.push).apply;
|
|
9065
9073
|
_e = [fileNames];
|
|
9066
9074
|
_f = [[]];
|
|
9067
|
-
return [4 /*yield*/,
|
|
9075
|
+
return [4 /*yield*/, listAllFiles(subPath, isRecursive, fs)];
|
|
9068
9076
|
case 5:
|
|
9069
9077
|
_d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent()).map(function (filename) { return filename; })]), false]))]));
|
|
9070
9078
|
_h.label = 6;
|
|
@@ -9089,7 +9097,7 @@ function $listAllFiles(path, isRecursive) {
|
|
|
9089
9097
|
}
|
|
9090
9098
|
/**
|
|
9091
9099
|
* TODO: [😶] Unite floder listing
|
|
9092
|
-
* Note: [
|
|
9100
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
9093
9101
|
* TODO: [🖇] What about symlinks?
|
|
9094
9102
|
*/
|
|
9095
9103
|
|
|
@@ -9198,17 +9206,18 @@ function createCollectionFromDirectory(path, tools, options) {
|
|
|
9198
9206
|
return __generator(this, function (_f) {
|
|
9199
9207
|
switch (_f.label) {
|
|
9200
9208
|
case 0:
|
|
9201
|
-
if (!$isRunningInNode()) {
|
|
9202
|
-
throw new Error('Function `createCollectionFromDirectory` can only be run in Node.js environment because it reads the file system.');
|
|
9203
|
-
}
|
|
9204
9209
|
if (!(tools === undefined)) return [3 /*break*/, 2];
|
|
9205
9210
|
return [4 /*yield*/, $provideExecutionToolsForNode()];
|
|
9206
9211
|
case 1:
|
|
9207
9212
|
tools = _f.sent();
|
|
9208
9213
|
_f.label = 2;
|
|
9209
9214
|
case 2:
|
|
9215
|
+
if (tools === undefined || tools.fs === undefined) {
|
|
9216
|
+
throw new EnvironmentMismatchError('Can not create collection without filesystem tools');
|
|
9217
|
+
// <- TODO: [🧠] What is the best error type here`
|
|
9218
|
+
}
|
|
9210
9219
|
makedLibraryFilePath = join(path, "".concat(PIPELINE_COLLECTION_BASE_FILENAME, ".json"));
|
|
9211
|
-
return [4 /*yield*/,
|
|
9220
|
+
return [4 /*yield*/, isFileExisting(makedLibraryFilePath, tools.fs)];
|
|
9212
9221
|
case 3:
|
|
9213
9222
|
if (!(_f.sent())) {
|
|
9214
9223
|
console.info(colors.yellow("Tip: Prebuild your pipeline collection (file with supposed prebuild ".concat(makedLibraryFilePath, " not found) with CLI util \"ptbk make\" to speed up the collection creation.")));
|
|
@@ -9228,7 +9237,7 @@ function createCollectionFromDirectory(path, tools, options) {
|
|
|
9228
9237
|
if (isVerbose) {
|
|
9229
9238
|
console.info(colors.cyan("Creating pipeline collection from path ".concat(path.split('\\').join('/'))));
|
|
9230
9239
|
}
|
|
9231
|
-
return [4 /*yield*/,
|
|
9240
|
+
return [4 /*yield*/, listAllFiles(path, isRecursive, tools.fs)];
|
|
9232
9241
|
case 1:
|
|
9233
9242
|
fileNames = _b.sent();
|
|
9234
9243
|
// Note: First load all .ptbk.json and then .ptbk.md files
|
|
@@ -9376,8 +9385,8 @@ function createCollectionFromDirectory(path, tools, options) {
|
|
|
9376
9385
|
});
|
|
9377
9386
|
}
|
|
9378
9387
|
/**
|
|
9379
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9380
9388
|
* TODO: [🖇] What about symlinks? Maybe option isSymlinksFollowed
|
|
9389
|
+
* TODO: Maybe move from `@promptbook/node` to `@promptbook/core` as we removes direct dependency on `fs`
|
|
9381
9390
|
*/
|
|
9382
9391
|
|
|
9383
9392
|
/**
|
|
@@ -9455,7 +9464,8 @@ function nameToSubfolderPath(name) {
|
|
|
9455
9464
|
* @public exported from `@promptbook/node`
|
|
9456
9465
|
*/
|
|
9457
9466
|
var FileCacheStorage = /** @class */ (function () {
|
|
9458
|
-
function FileCacheStorage(options) {
|
|
9467
|
+
function FileCacheStorage(tools, options) {
|
|
9468
|
+
this.tools = tools;
|
|
9459
9469
|
this.options = options;
|
|
9460
9470
|
if (!$isRunningInNode()) {
|
|
9461
9471
|
throw new EnvironmentMismatchError("FileCacheStorage works only in Node.js environment");
|
|
@@ -9481,7 +9491,7 @@ var FileCacheStorage = /** @class */ (function () {
|
|
|
9481
9491
|
switch (_a.label) {
|
|
9482
9492
|
case 0:
|
|
9483
9493
|
filename = this.getFilenameForKey(key);
|
|
9484
|
-
return [4 /*yield*/,
|
|
9494
|
+
return [4 /*yield*/, isFileExisting(filename, this.tools.fs)];
|
|
9485
9495
|
case 1:
|
|
9486
9496
|
if (!(_a.sent())) {
|
|
9487
9497
|
return [2 /*return*/, null];
|
|
@@ -9747,5 +9757,5 @@ function $execCommands(_a) {
|
|
|
9747
9757
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9748
9758
|
*/
|
|
9749
9759
|
|
|
9750
|
-
export { $execCommand, $execCommands, $provideExecutionToolsForNode, $provideLlmToolsConfigurationFromEnv, $provideLlmToolsFromEnv, $provideScrapersForNode, FileCacheStorage, PROMPTBOOK_VERSION, createCollectionFromDirectory };
|
|
9760
|
+
export { $execCommand, $execCommands, $provideExecutionToolsForNode, $provideFilesystemForNode, $provideLlmToolsConfigurationFromEnv, $provideLlmToolsFromEnv, $provideScrapersForNode, FileCacheStorage, PROMPTBOOK_VERSION, createCollectionFromDirectory };
|
|
9751
9761
|
//# sourceMappingURL=index.es.js.map
|