@promptbook/pdf 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 +2 -2
- 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
|
@@ -257,7 +257,7 @@ Or you can install them separately:
|
|
|
257
257
|
- **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
|
|
258
258
|
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Usefull templates and examples of books which can be used as a starting point
|
|
259
259
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
260
|
-
- **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
260
|
+
- ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
261
261
|
|
|
262
262
|
|
|
263
263
|
|
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
|
|
@@ -740,7 +740,7 @@ function checkSerializableAsJson(options) {
|
|
|
740
740
|
if (!(error instanceof Error)) {
|
|
741
741
|
throw error;
|
|
742
742
|
}
|
|
743
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.
|
|
743
|
+
throw new UnexpectedError(spaceTrim$1(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 "); }));
|
|
744
744
|
}
|
|
745
745
|
/*
|
|
746
746
|
TODO: [0] Is there some more elegant way to check circular references?
|
|
@@ -3298,21 +3298,44 @@ function isValidFilePath(filename) {
|
|
|
3298
3298
|
if (typeof filename !== 'string') {
|
|
3299
3299
|
return false;
|
|
3300
3300
|
}
|
|
3301
|
+
if (filename.split('\n').length > 1) {
|
|
3302
|
+
return false;
|
|
3303
|
+
}
|
|
3304
|
+
if (filename.split(' ').length >
|
|
3305
|
+
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
3306
|
+
return false;
|
|
3307
|
+
}
|
|
3301
3308
|
var filenameSlashes = filename.split('\\').join('/');
|
|
3302
3309
|
// Absolute Unix path: /hello.txt
|
|
3303
3310
|
if (/^(\/)/i.test(filenameSlashes)) {
|
|
3311
|
+
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
3304
3312
|
return true;
|
|
3305
3313
|
}
|
|
3306
3314
|
// Absolute Windows path: /hello.txt
|
|
3307
3315
|
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
3316
|
+
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
3308
3317
|
return true;
|
|
3309
3318
|
}
|
|
3310
3319
|
// Relative path: ./hello.txt
|
|
3311
3320
|
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
3321
|
+
// console.log(filename, 'Relative path: ./hello.txt');
|
|
3322
|
+
return true;
|
|
3323
|
+
}
|
|
3324
|
+
// Allow paths like foo/hello
|
|
3325
|
+
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
3326
|
+
// console.log(filename, 'Allow paths like foo/hello');
|
|
3327
|
+
return true;
|
|
3328
|
+
}
|
|
3329
|
+
// Allow paths like hello.book
|
|
3330
|
+
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
3331
|
+
// console.log(filename, 'Allow paths like hello.book');
|
|
3312
3332
|
return true;
|
|
3313
3333
|
}
|
|
3314
3334
|
return false;
|
|
3315
3335
|
}
|
|
3336
|
+
/**
|
|
3337
|
+
* TODO: [🍏] Implement for MacOs
|
|
3338
|
+
*/
|
|
3316
3339
|
|
|
3317
3340
|
/**
|
|
3318
3341
|
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
@@ -3337,6 +3360,9 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
3337
3360
|
}
|
|
3338
3361
|
});
|
|
3339
3362
|
}); };
|
|
3363
|
+
/**
|
|
3364
|
+
* TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
|
|
3365
|
+
*/
|
|
3340
3366
|
|
|
3341
3367
|
/**
|
|
3342
3368
|
* @@@
|
|
@@ -3404,7 +3430,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3404
3430
|
},
|
|
3405
3431
|
}];
|
|
3406
3432
|
case 2:
|
|
3407
|
-
if (!
|
|
3433
|
+
if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
|
|
3408
3434
|
if (tools.fs === undefined) {
|
|
3409
3435
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
3410
3436
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -3419,7 +3445,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3419
3445
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3420
3446
|
case 3:
|
|
3421
3447
|
if (!(_f.sent())) {
|
|
3422
|
-
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 "); }));
|
|
3448
|
+
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(sourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
|
|
3423
3449
|
}
|
|
3424
3450
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3425
3451
|
return [2 /*return*/, {
|
|
@@ -3827,7 +3853,7 @@ function extractVariablesFromScript(script) {
|
|
|
3827
3853
|
if (!(error instanceof Error)) {
|
|
3828
3854
|
throw error;
|
|
3829
3855
|
}
|
|
3830
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Can not extract variables from the script\n
|
|
3856
|
+
throw new ParseError(spaceTrim(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)
|
|
3831
3857
|
.map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
|
|
3832
3858
|
.join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
|
|
3833
3859
|
}
|