@promptbook/pdf 0.81.0-11 → 0.81.0-12
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/utils.index.d.ts +2 -0
- package/esm/typings/src/other/templates/getBookTemplate.d.ts +3 -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
|
@@ -68,6 +68,7 @@ import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
|
68
68
|
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
69
69
|
import { unwrapResult } from '../utils/unwrapResult';
|
|
70
70
|
import { isValidEmail } from '../utils/validators/email/isValidEmail';
|
|
71
|
+
import { isPathRoot } from '../utils/validators/filePath/isPathRoot';
|
|
71
72
|
import { isValidFilePath } from '../utils/validators/filePath/isValidFilePath';
|
|
72
73
|
import { isValidJavascriptName } from '../utils/validators/javascriptName/isValidJavascriptName';
|
|
73
74
|
import { isValidPromptbookVersion } from '../utils/validators/semanticVersion/isValidPromptbookVersion';
|
|
@@ -147,6 +148,7 @@ export { trimCodeBlock };
|
|
|
147
148
|
export { trimEndOfCodeBlock };
|
|
148
149
|
export { unwrapResult };
|
|
149
150
|
export { isValidEmail };
|
|
151
|
+
export { isPathRoot };
|
|
150
152
|
export { isValidFilePath };
|
|
151
153
|
export { isValidJavascriptName };
|
|
152
154
|
export { isValidPromptbookVersion };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PipelineCollection } from '../../collection/PipelineCollection';
|
|
2
1
|
import type { string_formfactor_name } from '../../formfactors/_common/string_formfactor_name';
|
|
3
2
|
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
4
3
|
/**
|
|
@@ -7,15 +6,14 @@ import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
|
7
6
|
* @singleton
|
|
8
7
|
* @private internal cache of `getBookTemplate`
|
|
9
8
|
*/
|
|
10
|
-
export declare let
|
|
9
|
+
export declare let pipelines: Array<PipelineJson> | null;
|
|
11
10
|
/**
|
|
12
11
|
* Get template for new book
|
|
13
12
|
*
|
|
14
13
|
* @public exported from `@promptbook/templates`
|
|
15
14
|
*/
|
|
16
|
-
export declare function getBookTemplate(formfactorName: string_formfactor_name): PipelineJson
|
|
15
|
+
export declare function getBookTemplate(formfactorName: string_formfactor_name): ReadonlyArray<PipelineJson>;
|
|
17
16
|
/**
|
|
18
|
-
* TODO:
|
|
17
|
+
* TODO: Unit test
|
|
19
18
|
* TODO: [🧠] Which is the best place for this function
|
|
20
|
-
* TODO: !!!!!! `book string template notation
|
|
21
19
|
*/
|
|
@@ -5,3 +5,6 @@ import type { PromptbookFetch } from '../../../execution/PromptbookFetch';
|
|
|
5
5
|
* @private as default `fetch` function used in Promptbook scrapers
|
|
6
6
|
*/
|
|
7
7
|
export declare const scraperFetch: PromptbookFetch;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
|
|
10
|
+
*/
|
|
@@ -9,5 +9,6 @@ import type { really_any } from '../../../utils/organization/really_any';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function preserve(func: (...params: ReadonlyArray<really_any>) => unknown): void;
|
|
11
11
|
/**
|
|
12
|
+
* TODO: Probbably remove in favour of `keepImported`
|
|
12
13
|
* TODO: !! [1] This maybe does memory leak
|
|
13
14
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_dirname } from '../../../types/typeAliases';
|
|
2
|
+
import type { string_filename } from '../../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Determines if the given path is a root path.
|
|
5
|
+
*
|
|
6
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
7
|
+
* @public exported from `@promptbook/utils`
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPathRoot(value: string_dirname | string_filename): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🍏] Make for MacOS paths
|
|
12
|
+
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
2
|
+
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
3
|
+
import type { PipelineString } from '../pipeline/PipelineString';
|
|
4
|
+
import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
|
|
5
|
+
import type { string_filename } from '../types/typeAliases';
|
|
6
|
+
import type { string_pipeline_url } from '../types/typeAliases';
|
|
7
|
+
/**
|
|
8
|
+
* @see ./wizzard.ts `getPipeline` method
|
|
9
|
+
*
|
|
10
|
+
* @private usable through `ptbk run` and `@prompbook/wizzard`
|
|
11
|
+
*/
|
|
12
|
+
export declare function $getCompiledBook(tools: Required<Pick<ExecutionTools, 'fs' | 'fetch'>>, pipelineSource: string_filename | string_pipeline_url | PipelineString, options?: PrepareAndScrapeOptions): Promise<PipelineJson>;
|
|
13
|
+
/**
|
|
14
|
+
* TODO: Write unit test
|
|
15
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
16
|
+
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Promisable } from 'type-fest';
|
|
2
|
-
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
3
2
|
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
4
3
|
import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
|
|
4
|
+
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
5
5
|
import type { PipelineString } from '../pipeline/PipelineString';
|
|
6
6
|
import type { TaskProgress } from '../types/TaskProgress';
|
|
7
7
|
import type { InputParameters } from '../types/typeAliases';
|
|
@@ -23,7 +23,7 @@ declare class Wizzard {
|
|
|
23
23
|
*
|
|
24
24
|
* @param pipelineSource
|
|
25
25
|
*/
|
|
26
|
-
getExecutionTools(): Promise<ExecutionTools
|
|
26
|
+
getExecutionTools(): Promise<Required<Pick<ExecutionTools, 'fs' | 'fetch'>>>;
|
|
27
27
|
/**
|
|
28
28
|
* TODO: Make standalone function from this exported from node and used here and in `ptbk run`
|
|
29
29
|
* @@@!!!
|
|
@@ -34,7 +34,7 @@ declare class Wizzard {
|
|
|
34
34
|
*
|
|
35
35
|
* @param pipelineSource
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
getCompiledBook(pipelineSource: string_filename | string_pipeline_url | PipelineString): Promise<PipelineJson>;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* 🧙♂️ @@@
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/pdf",
|
|
3
|
-
"version": "0.81.0-
|
|
3
|
+
"version": "0.81.0-12",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"--note-0": " <- [🐊]",
|
|
6
6
|
"private": false,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"module": "./esm/index.es.js",
|
|
55
55
|
"typings": "./esm/typings/src/_packages/pdf.index.d.ts",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@promptbook/core": "0.81.0-
|
|
57
|
+
"@promptbook/core": "0.81.0-12"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"crypto-js": "4.2.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @generated
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
27
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-11';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -742,7 +742,7 @@
|
|
|
742
742
|
if (!(error instanceof Error)) {
|
|
743
743
|
throw error;
|
|
744
744
|
}
|
|
745
|
-
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.
|
|
745
|
+
throw new UnexpectedError(spaceTrim__default["default"](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 "); }));
|
|
746
746
|
}
|
|
747
747
|
/*
|
|
748
748
|
TODO: [0] Is there some more elegant way to check circular references?
|
|
@@ -3300,21 +3300,44 @@
|
|
|
3300
3300
|
if (typeof filename !== 'string') {
|
|
3301
3301
|
return false;
|
|
3302
3302
|
}
|
|
3303
|
+
if (filename.split('\n').length > 1) {
|
|
3304
|
+
return false;
|
|
3305
|
+
}
|
|
3306
|
+
if (filename.split(' ').length >
|
|
3307
|
+
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
3308
|
+
return false;
|
|
3309
|
+
}
|
|
3303
3310
|
var filenameSlashes = filename.split('\\').join('/');
|
|
3304
3311
|
// Absolute Unix path: /hello.txt
|
|
3305
3312
|
if (/^(\/)/i.test(filenameSlashes)) {
|
|
3313
|
+
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
3306
3314
|
return true;
|
|
3307
3315
|
}
|
|
3308
3316
|
// Absolute Windows path: /hello.txt
|
|
3309
3317
|
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
3318
|
+
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
3310
3319
|
return true;
|
|
3311
3320
|
}
|
|
3312
3321
|
// Relative path: ./hello.txt
|
|
3313
3322
|
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
3323
|
+
// console.log(filename, 'Relative path: ./hello.txt');
|
|
3324
|
+
return true;
|
|
3325
|
+
}
|
|
3326
|
+
// Allow paths like foo/hello
|
|
3327
|
+
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
3328
|
+
// console.log(filename, 'Allow paths like foo/hello');
|
|
3329
|
+
return true;
|
|
3330
|
+
}
|
|
3331
|
+
// Allow paths like hello.book
|
|
3332
|
+
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
3333
|
+
// console.log(filename, 'Allow paths like hello.book');
|
|
3314
3334
|
return true;
|
|
3315
3335
|
}
|
|
3316
3336
|
return false;
|
|
3317
3337
|
}
|
|
3338
|
+
/**
|
|
3339
|
+
* TODO: [🍏] Implement for MacOs
|
|
3340
|
+
*/
|
|
3318
3341
|
|
|
3319
3342
|
/**
|
|
3320
3343
|
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
@@ -3339,6 +3362,9 @@
|
|
|
3339
3362
|
}
|
|
3340
3363
|
});
|
|
3341
3364
|
}); };
|
|
3365
|
+
/**
|
|
3366
|
+
* TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
|
|
3367
|
+
*/
|
|
3342
3368
|
|
|
3343
3369
|
/**
|
|
3344
3370
|
* @@@
|
|
@@ -3406,7 +3432,7 @@
|
|
|
3406
3432
|
},
|
|
3407
3433
|
}];
|
|
3408
3434
|
case 2:
|
|
3409
|
-
if (!
|
|
3435
|
+
if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
|
|
3410
3436
|
if (tools.fs === undefined) {
|
|
3411
3437
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
3412
3438
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -3421,7 +3447,7 @@
|
|
|
3421
3447
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3422
3448
|
case 3:
|
|
3423
3449
|
if (!(_f.sent())) {
|
|
3424
|
-
throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
3450
|
+
throw new NotFoundError(spaceTrim__default["default"](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 "); }));
|
|
3425
3451
|
}
|
|
3426
3452
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3427
3453
|
return [2 /*return*/, {
|
|
@@ -3829,7 +3855,7 @@
|
|
|
3829
3855
|
if (!(error instanceof Error)) {
|
|
3830
3856
|
throw error;
|
|
3831
3857
|
}
|
|
3832
|
-
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n
|
|
3858
|
+
throw new ParseError(spaceTrim.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)
|
|
3833
3859
|
.map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
|
|
3834
3860
|
.join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
|
|
3835
3861
|
}
|