@promptbook/markdown-utils 0.81.0-11 → 0.81.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 +1 -1
- package/esm/index.es.js +31 -5
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/templates.index.d.ts +2 -2
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/other/templates/{getBookTemplate.d.ts → getBookTemplates.d.ts} +5 -5
- package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +3 -0
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -0
- package/esm/typings/src/utils/validators/filePath/isPathRoot.d.ts +12 -0
- package/esm/typings/src/utils/validators/filePath/isPathRoot.test.d.ts +4 -0
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +3 -0
- package/esm/typings/src/wizzard/$getCompiledBook.d.ts +16 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +3 -3
- package/package.json +1 -1
- package/umd/index.umd.js +31 -5
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +0 -8
package/README.md
CHANGED
|
@@ -255,7 +255,7 @@ Or you can install them separately:
|
|
|
255
255
|
- **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
|
|
256
256
|
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Usefull templates and examples of books which can be used as a starting point
|
|
257
257
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
258
|
-
- **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
258
|
+
- ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
259
259
|
|
|
260
260
|
|
|
261
261
|
|
package/esm/index.es.js
CHANGED
|
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
22
22
|
* @generated
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-12';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -925,7 +925,7 @@ function checkSerializableAsJson(options) {
|
|
|
925
925
|
if (!(error instanceof Error)) {
|
|
926
926
|
throw error;
|
|
927
927
|
}
|
|
928
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.
|
|
928
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.stack || error.message), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
|
|
929
929
|
}
|
|
930
930
|
/*
|
|
931
931
|
TODO: [0] Is there some more elegant way to check circular references?
|
|
@@ -3480,21 +3480,44 @@ function isValidFilePath(filename) {
|
|
|
3480
3480
|
if (typeof filename !== 'string') {
|
|
3481
3481
|
return false;
|
|
3482
3482
|
}
|
|
3483
|
+
if (filename.split('\n').length > 1) {
|
|
3484
|
+
return false;
|
|
3485
|
+
}
|
|
3486
|
+
if (filename.split(' ').length >
|
|
3487
|
+
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
3488
|
+
return false;
|
|
3489
|
+
}
|
|
3483
3490
|
var filenameSlashes = filename.split('\\').join('/');
|
|
3484
3491
|
// Absolute Unix path: /hello.txt
|
|
3485
3492
|
if (/^(\/)/i.test(filenameSlashes)) {
|
|
3493
|
+
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
3486
3494
|
return true;
|
|
3487
3495
|
}
|
|
3488
3496
|
// Absolute Windows path: /hello.txt
|
|
3489
3497
|
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
3498
|
+
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
3490
3499
|
return true;
|
|
3491
3500
|
}
|
|
3492
3501
|
// Relative path: ./hello.txt
|
|
3493
3502
|
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
3503
|
+
// console.log(filename, 'Relative path: ./hello.txt');
|
|
3504
|
+
return true;
|
|
3505
|
+
}
|
|
3506
|
+
// Allow paths like foo/hello
|
|
3507
|
+
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
3508
|
+
// console.log(filename, 'Allow paths like foo/hello');
|
|
3509
|
+
return true;
|
|
3510
|
+
}
|
|
3511
|
+
// Allow paths like hello.book
|
|
3512
|
+
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
3513
|
+
// console.log(filename, 'Allow paths like hello.book');
|
|
3494
3514
|
return true;
|
|
3495
3515
|
}
|
|
3496
3516
|
return false;
|
|
3497
3517
|
}
|
|
3518
|
+
/**
|
|
3519
|
+
* TODO: [🍏] Implement for MacOs
|
|
3520
|
+
*/
|
|
3498
3521
|
|
|
3499
3522
|
/**
|
|
3500
3523
|
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
@@ -3519,6 +3542,9 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
3519
3542
|
}
|
|
3520
3543
|
});
|
|
3521
3544
|
}); };
|
|
3545
|
+
/**
|
|
3546
|
+
* TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
|
|
3547
|
+
*/
|
|
3522
3548
|
|
|
3523
3549
|
/**
|
|
3524
3550
|
* @@@
|
|
@@ -3586,7 +3612,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3586
3612
|
},
|
|
3587
3613
|
}];
|
|
3588
3614
|
case 2:
|
|
3589
|
-
if (!
|
|
3615
|
+
if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
|
|
3590
3616
|
if (tools.fs === undefined) {
|
|
3591
3617
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
3592
3618
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -3601,7 +3627,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3601
3627
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3602
3628
|
case 3:
|
|
3603
3629
|
if (!(_f.sent())) {
|
|
3604
|
-
throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
3630
|
+
throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(sourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
|
|
3605
3631
|
}
|
|
3606
3632
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3607
3633
|
return [2 /*return*/, {
|
|
@@ -4009,7 +4035,7 @@ function extractVariablesFromScript(script) {
|
|
|
4009
4035
|
if (!(error instanceof Error)) {
|
|
4010
4036
|
throw error;
|
|
4011
4037
|
}
|
|
4012
|
-
throw new ParseError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n
|
|
4038
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n ".concat(block(error.stack || error.message), "\n\n Found variables:\n ").concat(Array.from(variables)
|
|
4013
4039
|
.map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
|
|
4014
4040
|
.join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
|
|
4015
4041
|
}
|