@promptbook/node 0.63.0-4 → 0.63.0-6
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 +1 -1
- package/esm/index.es.js +106 -33
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +2 -0
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -0
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -0
- package/esm/typings/src/config.d.ts +7 -1
- package/esm/typings/src/utils/files/isDirectoryExisting.d.ts +13 -0
- package/esm/typings/src/utils/files/isDirectoryExisting.test.d.ts +1 -0
- package/esm/typings/src/utils/files/isFileExisting.d.ts +12 -0
- package/esm/typings/src/utils/files/isFileExisting.test.d.ts +1 -0
- package/esm/typings/src/utils/files/listAllFiles.d.ts +1 -0
- package/esm/typings/src/utils/files/listAllFiles.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +105 -32
- package/umd/index.umd.js.map +1 -1
|
@@ -6,5 +6,7 @@ import type { Command as Program } from 'commander';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function initializeMakeCommand(program: Program): void;
|
|
8
8
|
/**
|
|
9
|
+
* TODO: [0] DRY Javascript and typescript - Maybe make ONLY typescript and for javascript just remove types
|
|
9
10
|
* Note: [🟡] This code should never be published outside of `@promptbook/cli`
|
|
11
|
+
* TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
|
|
10
12
|
*/
|
|
@@ -7,4 +7,5 @@ import type { Command as Program } from 'commander';
|
|
|
7
7
|
export declare function initializePrettifyCommand(program: Program): void;
|
|
8
8
|
/**
|
|
9
9
|
* Note: [🟡] This code should never be published outside of `@promptbook/cli`
|
|
10
|
+
* TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
|
|
10
11
|
*/
|
|
@@ -45,4 +45,5 @@ export declare function createCollectionFromDirectory(path: string_folder_path,
|
|
|
45
45
|
export {};
|
|
46
46
|
/**
|
|
47
47
|
* Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
|
|
48
|
+
* TODO: [🖇] What about symlinks? Maybe option isSymlinksFollowed
|
|
48
49
|
*/
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @private within the repository
|
|
5
5
|
*/
|
|
6
|
-
export declare const GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This
|
|
6
|
+
export declare const GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so that any manual changes will be overwritten";
|
|
7
|
+
/**
|
|
8
|
+
* Warning message for the generated sections and files files
|
|
9
|
+
*
|
|
10
|
+
* @private within the repository
|
|
11
|
+
*/
|
|
12
|
+
export declare const GENERATOR_WARNING_BY_PROMPTBOOK_CLI = "\u26A0\uFE0F WARNING: This code has been generated by `@promptbook/cli` so that any manual changes will be overwritten";
|
|
7
13
|
/**
|
|
8
14
|
* The maximum number of iterations for a loops
|
|
9
15
|
*
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { string_folder_path } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the directory exists
|
|
4
|
+
*
|
|
5
|
+
* @private within the repository
|
|
6
|
+
*/
|
|
7
|
+
export declare function isDirectoryExisting(directoryPath: string_folder_path): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
|
|
10
|
+
* TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
|
|
11
|
+
* TODO: [🧠][📂] "directory" vs "folder"
|
|
12
|
+
* TODO: [🖇] What about symlinks?
|
|
13
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_file_path } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the file exists
|
|
4
|
+
*
|
|
5
|
+
* @private within the repository
|
|
6
|
+
*/
|
|
7
|
+
export declare function isFileExisting(filePath: string_file_path): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
|
|
10
|
+
* TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
|
|
11
|
+
* TODO: [🖇] What about symlinks?
|
|
12
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -11,4 +11,5 @@ import type { string_folder_path } from '../../types/typeAliases';
|
|
|
11
11
|
export declare function listAllFiles(path: string_folder_path, isRecursive: boolean): Promise<Array<string_file_path>>;
|
|
12
12
|
/**
|
|
13
13
|
* Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
|
|
14
|
+
* TODO: [🖇] What about symlinks?
|
|
14
15
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.63.0-
|
|
3
|
+
"version": "0.63.0-6",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.63.0-
|
|
50
|
+
"@promptbook/core": "0.63.0-6"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@anthropic-ai/sdk": "0.21.1",
|
package/umd/index.umd.js
CHANGED
|
@@ -33,10 +33,11 @@
|
|
|
33
33
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
34
34
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
35
35
|
|
|
36
|
+
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
36
37
|
/**
|
|
37
38
|
* The version of the Promptbook library
|
|
38
39
|
*/
|
|
39
|
-
var PROMPTBOOK_VERSION = '0.63.0-
|
|
40
|
+
var PROMPTBOOK_VERSION = '0.63.0-5';
|
|
40
41
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
41
42
|
|
|
42
43
|
/*! *****************************************************************************
|
|
@@ -203,6 +204,7 @@
|
|
|
203
204
|
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
204
205
|
*/
|
|
205
206
|
|
|
207
|
+
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
206
208
|
/**
|
|
207
209
|
* The maximum number of iterations for a loops
|
|
208
210
|
*
|
|
@@ -710,7 +712,7 @@
|
|
|
710
712
|
});
|
|
711
713
|
}
|
|
712
714
|
|
|
713
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.63.0-
|
|
715
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.63.0-5",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-5",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.63.0-5",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-5",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.63.0-5",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-5",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.63.0-5",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-5",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
714
716
|
|
|
715
717
|
/**
|
|
716
718
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -5810,6 +5812,75 @@
|
|
|
5810
5812
|
return CollectionError;
|
|
5811
5813
|
}(Error));
|
|
5812
5814
|
|
|
5815
|
+
/**
|
|
5816
|
+
* Checks if the file exists
|
|
5817
|
+
*
|
|
5818
|
+
* @private within the repository
|
|
5819
|
+
*/
|
|
5820
|
+
function isFileExisting(filePath) {
|
|
5821
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5822
|
+
var isReadAccessAllowed, isFile;
|
|
5823
|
+
return __generator(this, function (_a) {
|
|
5824
|
+
switch (_a.label) {
|
|
5825
|
+
case 0: return [4 /*yield*/, promises.access(filePath, promises.constants.R_OK)
|
|
5826
|
+
.then(function () { return true; })
|
|
5827
|
+
.catch(function () { return false; })];
|
|
5828
|
+
case 1:
|
|
5829
|
+
isReadAccessAllowed = _a.sent();
|
|
5830
|
+
if (!isReadAccessAllowed) {
|
|
5831
|
+
return [2 /*return*/, false];
|
|
5832
|
+
}
|
|
5833
|
+
return [4 /*yield*/, promises.stat(filePath)
|
|
5834
|
+
.then(function (fileStat) { return fileStat.isFile(); })
|
|
5835
|
+
.catch(function () { return false; })];
|
|
5836
|
+
case 2:
|
|
5837
|
+
isFile = _a.sent();
|
|
5838
|
+
return [2 /*return*/, isFile];
|
|
5839
|
+
}
|
|
5840
|
+
});
|
|
5841
|
+
});
|
|
5842
|
+
}
|
|
5843
|
+
/**
|
|
5844
|
+
* Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
|
|
5845
|
+
* TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
|
|
5846
|
+
* TODO: [🖇] What about symlinks?
|
|
5847
|
+
*/
|
|
5848
|
+
|
|
5849
|
+
/**
|
|
5850
|
+
* Checks if the directory exists
|
|
5851
|
+
*
|
|
5852
|
+
* @private within the repository
|
|
5853
|
+
*/
|
|
5854
|
+
function isDirectoryExisting(directoryPath) {
|
|
5855
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5856
|
+
var isReadAccessAllowed, isDirectory;
|
|
5857
|
+
return __generator(this, function (_a) {
|
|
5858
|
+
switch (_a.label) {
|
|
5859
|
+
case 0: return [4 /*yield*/, promises.access(directoryPath, promises.constants.R_OK)
|
|
5860
|
+
.then(function () { return true; })
|
|
5861
|
+
.catch(function () { return false; })];
|
|
5862
|
+
case 1:
|
|
5863
|
+
isReadAccessAllowed = _a.sent();
|
|
5864
|
+
if (!isReadAccessAllowed) {
|
|
5865
|
+
return [2 /*return*/, false];
|
|
5866
|
+
}
|
|
5867
|
+
return [4 /*yield*/, promises.stat(directoryPath)
|
|
5868
|
+
.then(function (fileStat) { return fileStat.isDirectory(); })
|
|
5869
|
+
.catch(function () { return false; })];
|
|
5870
|
+
case 2:
|
|
5871
|
+
isDirectory = _a.sent();
|
|
5872
|
+
return [2 /*return*/, isDirectory];
|
|
5873
|
+
}
|
|
5874
|
+
});
|
|
5875
|
+
});
|
|
5876
|
+
}
|
|
5877
|
+
/**
|
|
5878
|
+
* Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
|
|
5879
|
+
* TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
|
|
5880
|
+
* TODO: [🧠][📂] "directory" vs "folder"
|
|
5881
|
+
* TODO: [🖇] What about symlinks?
|
|
5882
|
+
*/
|
|
5883
|
+
|
|
5813
5884
|
/**
|
|
5814
5885
|
* Reads all files in the directory
|
|
5815
5886
|
*
|
|
@@ -5824,53 +5895,60 @@
|
|
|
5824
5895
|
var e_1, _g;
|
|
5825
5896
|
return __generator(this, function (_h) {
|
|
5826
5897
|
switch (_h.label) {
|
|
5827
|
-
case 0: return [4 /*yield*/,
|
|
5828
|
-
withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
|
|
5829
|
-
})];
|
|
5898
|
+
case 0: return [4 /*yield*/, isDirectoryExisting(path)];
|
|
5830
5899
|
case 1:
|
|
5900
|
+
if (!(_h.sent())) {
|
|
5901
|
+
throw new Error("Directory \"".concat(path, "\" does not exist or is not readable"));
|
|
5902
|
+
// <- TODO: Use some custom error class
|
|
5903
|
+
}
|
|
5904
|
+
return [4 /*yield*/, promises.readdir(path, {
|
|
5905
|
+
withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
|
|
5906
|
+
})];
|
|
5907
|
+
case 2:
|
|
5831
5908
|
dirents = _h.sent();
|
|
5832
5909
|
fileNames = dirents.filter(function (dirent) { return dirent.isFile(); }).map(function (_a) {
|
|
5833
5910
|
var name = _a.name;
|
|
5834
5911
|
return posix.join(path, name);
|
|
5835
5912
|
});
|
|
5836
|
-
if (!isRecursive) return [3 /*break*/,
|
|
5837
|
-
_h.label = 2;
|
|
5838
|
-
case 2:
|
|
5839
|
-
_h.trys.push([2, 7, 8, 9]);
|
|
5840
|
-
_a = __values(dirents.filter(function (dirent) { return dirent.isDirectory(); })), _b = _a.next();
|
|
5913
|
+
if (!isRecursive) return [3 /*break*/, 10];
|
|
5841
5914
|
_h.label = 3;
|
|
5842
5915
|
case 3:
|
|
5843
|
-
|
|
5916
|
+
_h.trys.push([3, 8, 9, 10]);
|
|
5917
|
+
_a = __values(dirents.filter(function (dirent) { return dirent.isDirectory(); })), _b = _a.next();
|
|
5918
|
+
_h.label = 4;
|
|
5919
|
+
case 4:
|
|
5920
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
5844
5921
|
dirent = _b.value;
|
|
5845
5922
|
subPath = posix.join(path, dirent.name);
|
|
5846
5923
|
_d = (_c = fileNames.push).apply;
|
|
5847
5924
|
_e = [fileNames];
|
|
5848
5925
|
_f = [[]];
|
|
5849
5926
|
return [4 /*yield*/, listAllFiles(subPath, isRecursive)];
|
|
5850
|
-
case 4:
|
|
5851
|
-
_d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
|
|
5852
|
-
_h.label = 5;
|
|
5853
5927
|
case 5:
|
|
5928
|
+
_d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
|
|
5929
|
+
_h.label = 6;
|
|
5930
|
+
case 6:
|
|
5854
5931
|
_b = _a.next();
|
|
5855
|
-
return [3 /*break*/,
|
|
5856
|
-
case
|
|
5857
|
-
case
|
|
5932
|
+
return [3 /*break*/, 4];
|
|
5933
|
+
case 7: return [3 /*break*/, 10];
|
|
5934
|
+
case 8:
|
|
5858
5935
|
e_1_1 = _h.sent();
|
|
5859
5936
|
e_1 = { error: e_1_1 };
|
|
5860
|
-
return [3 /*break*/,
|
|
5861
|
-
case
|
|
5937
|
+
return [3 /*break*/, 10];
|
|
5938
|
+
case 9:
|
|
5862
5939
|
try {
|
|
5863
5940
|
if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
|
|
5864
5941
|
}
|
|
5865
5942
|
finally { if (e_1) throw e_1.error; }
|
|
5866
5943
|
return [7 /*endfinally*/];
|
|
5867
|
-
case
|
|
5944
|
+
case 10: return [2 /*return*/, fileNames];
|
|
5868
5945
|
}
|
|
5869
5946
|
});
|
|
5870
5947
|
});
|
|
5871
5948
|
}
|
|
5872
5949
|
/**
|
|
5873
5950
|
* Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
|
|
5951
|
+
* TODO: [🖇] What about symlinks?
|
|
5874
5952
|
*/
|
|
5875
5953
|
|
|
5876
5954
|
/**
|
|
@@ -5991,7 +6069,7 @@
|
|
|
5991
6069
|
*/
|
|
5992
6070
|
function createCollectionFromDirectory(path$1, options) {
|
|
5993
6071
|
return __awaiter(this, void 0, void 0, function () {
|
|
5994
|
-
var makedLibraryFilePath,
|
|
6072
|
+
var makedLibraryFilePath, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashedOnError, collection;
|
|
5995
6073
|
var _this = this;
|
|
5996
6074
|
return __generator(this, function (_f) {
|
|
5997
6075
|
switch (_f.label) {
|
|
@@ -6000,12 +6078,9 @@
|
|
|
6000
6078
|
throw new Error('Function `createCollectionFromDirectory` can only be run in Node.js environment because it reads the file system.');
|
|
6001
6079
|
}
|
|
6002
6080
|
makedLibraryFilePath = path.join(path$1, "".concat(PIPELINE_COLLECTION_BASE_FILENAME, ".json"));
|
|
6003
|
-
return [4 /*yield*/,
|
|
6004
|
-
.then(function () { return true; })
|
|
6005
|
-
.catch(function () { return false; })];
|
|
6081
|
+
return [4 /*yield*/, isFileExisting(makedLibraryFilePath)];
|
|
6006
6082
|
case 1:
|
|
6007
|
-
|
|
6008
|
-
if (!makedLibraryFileExists) {
|
|
6083
|
+
if (!(_f.sent())) {
|
|
6009
6084
|
console.info(colors__default["default"].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.")));
|
|
6010
6085
|
}
|
|
6011
6086
|
else {
|
|
@@ -6169,6 +6244,7 @@
|
|
|
6169
6244
|
}
|
|
6170
6245
|
/**
|
|
6171
6246
|
* Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
|
|
6247
|
+
* TODO: [🖇] What about symlinks? Maybe option isSymlinksFollowed
|
|
6172
6248
|
*/
|
|
6173
6249
|
|
|
6174
6250
|
/**
|
|
@@ -7336,17 +7412,14 @@
|
|
|
7336
7412
|
*/
|
|
7337
7413
|
FilesStorage.prototype.getItem = function (key) {
|
|
7338
7414
|
return __awaiter(this, void 0, void 0, function () {
|
|
7339
|
-
var filename,
|
|
7415
|
+
var filename, fileContent, value;
|
|
7340
7416
|
return __generator(this, function (_a) {
|
|
7341
7417
|
switch (_a.label) {
|
|
7342
7418
|
case 0:
|
|
7343
7419
|
filename = this.getFilenameForKey(key);
|
|
7344
|
-
return [4 /*yield*/,
|
|
7345
|
-
.then(function (fileStat) { return fileStat.isFile(); })
|
|
7346
|
-
.catch(function () { return false; })];
|
|
7420
|
+
return [4 /*yield*/, isFileExisting(filename)];
|
|
7347
7421
|
case 1:
|
|
7348
|
-
|
|
7349
|
-
if (!isFileExisting) {
|
|
7422
|
+
if (!(_a.sent())) {
|
|
7350
7423
|
return [2 /*return*/, null];
|
|
7351
7424
|
}
|
|
7352
7425
|
return [4 /*yield*/, promises.readFile(filename, 'utf-8')];
|