@promptbook/pdf 0.85.0-8 → 0.85.0
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 +0 -4
- package/esm/index.es.js +6 -58
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +0 -1
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +3 -3
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -2
- package/package.json +3 -3
- package/umd/index.umd.js +6 -58
- package/umd/index.umd.js.map +1 -1
|
@@ -8,7 +8,6 @@ import type { Command as Program } from 'commander';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function $initializeAboutCommand(program: Program): void;
|
|
10
10
|
/**
|
|
11
|
-
* TODO: !!! Test this in `deno`
|
|
12
11
|
* TODO: [🗽] Unite branding and make single place for it
|
|
13
12
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
14
13
|
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
@@ -6,7 +6,7 @@ import type { PipelineCollection } from '../PipelineCollection';
|
|
|
6
6
|
/**
|
|
7
7
|
* Options for `createCollectionFromDirectory` function
|
|
8
8
|
*
|
|
9
|
-
* Note: `rootDirname` is not needed because it is the folder in which `.book.md` file is located
|
|
9
|
+
* Note: `rootDirname` is not needed because it is the folder in which `.book` or `.book.md` file is located
|
|
10
10
|
* This is not same as `path` which is the first argument of `createCollectionFromDirectory` - it can be a subfolder
|
|
11
11
|
*/
|
|
12
12
|
type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions, 'rootDirname'> & {
|
|
@@ -51,13 +51,13 @@ type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions
|
|
|
51
51
|
*
|
|
52
52
|
* Note: Works only in Node.js environment because it reads the file system
|
|
53
53
|
*
|
|
54
|
-
* @param
|
|
54
|
+
* @param rootPath - path to the directory with pipelines
|
|
55
55
|
* @param tools - Execution tools to be used for pipeline preparation if needed - If not provided, `$provideExecutionToolsForNode` will be used
|
|
56
56
|
* @param options - Options for the collection creation
|
|
57
57
|
* @returns PipelineCollection
|
|
58
58
|
* @public exported from `@promptbook/node`
|
|
59
59
|
*/
|
|
60
|
-
export declare function createCollectionFromDirectory(
|
|
60
|
+
export declare function createCollectionFromDirectory(rootPath: string_dirname, tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options?: CreatePipelineCollectionFromDirectoryOptions): Promise<PipelineCollection>;
|
|
61
61
|
export {};
|
|
62
62
|
/**
|
|
63
63
|
* TODO: [🖇] What about symlinks? Maybe option isSymlinksFollowed
|
|
@@ -11,8 +11,7 @@ import type { RemoteServerOptions } from './types/RemoteServerOptions';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): IDestroyable;
|
|
13
13
|
/**
|
|
14
|
-
* TODO:
|
|
15
|
-
* TODO: !!!!!!! Allow to pass tokem here
|
|
14
|
+
* TODO: !! Add CORS and security - probbably via `helmet`
|
|
16
15
|
* TODO: [👩🏾🤝🧑🏾] Allow to pass custom fetch function here - PromptbookFetch
|
|
17
16
|
* TODO: Split this file into multiple functions - handler for each request
|
|
18
17
|
* TODO: Maybe use `$exportJson`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/pdf",
|
|
3
|
-
"version": "0.85.0
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"bugs": {
|
|
43
43
|
"url": "https://github.com/webgptorg/promptbook/issues"
|
|
44
44
|
},
|
|
45
|
-
"homepage": "https://
|
|
45
|
+
"homepage": "https://ptbk.io/",
|
|
46
46
|
"main": "./umd/index.umd.js",
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/pdf.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.85.0
|
|
50
|
+
"@promptbook/core": "0.85.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"crypto": "^1.0.1",
|
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-16';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1650,57 +1650,6 @@
|
|
|
1650
1650
|
return true;
|
|
1651
1651
|
}
|
|
1652
1652
|
|
|
1653
|
-
/**
|
|
1654
|
-
* Checks if an URL is reserved for private networks or localhost.
|
|
1655
|
-
*
|
|
1656
|
-
* Note: There are two simmilar functions:
|
|
1657
|
-
* - `isUrlOnPrivateNetwork` which tests full URL
|
|
1658
|
-
* - `isHostnameOnPrivateNetwork` *(this one)* which tests just hostname
|
|
1659
|
-
*
|
|
1660
|
-
* @public exported from `@promptbook/utils`
|
|
1661
|
-
*/
|
|
1662
|
-
function isHostnameOnPrivateNetwork(hostname) {
|
|
1663
|
-
if (hostname === 'example.com' ||
|
|
1664
|
-
hostname === 'localhost' ||
|
|
1665
|
-
hostname.endsWith('.localhost') ||
|
|
1666
|
-
hostname.endsWith('.local') ||
|
|
1667
|
-
hostname.endsWith('.test') ||
|
|
1668
|
-
hostname === '127.0.0.1' ||
|
|
1669
|
-
hostname === '::1') {
|
|
1670
|
-
return true;
|
|
1671
|
-
}
|
|
1672
|
-
if (hostname.includes(':')) {
|
|
1673
|
-
// IPv6
|
|
1674
|
-
var ipParts = hostname.split(':');
|
|
1675
|
-
return ipParts[0] === 'fc00' || ipParts[0] === 'fd00' || ipParts[0] === 'fe80';
|
|
1676
|
-
}
|
|
1677
|
-
else {
|
|
1678
|
-
// IPv4
|
|
1679
|
-
var ipParts = hostname.split('.').map(function (part) { return Number.parseInt(part, 10); });
|
|
1680
|
-
return (ipParts[0] === 10 ||
|
|
1681
|
-
(ipParts[0] === 172 && ipParts[1] >= 16 && ipParts[1] <= 31) ||
|
|
1682
|
-
(ipParts[0] === 192 && ipParts[1] === 168));
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
/**
|
|
1687
|
-
* Checks if an IP address or hostname is reserved for private networks or localhost.
|
|
1688
|
-
*
|
|
1689
|
-
* Note: There are two simmilar functions:
|
|
1690
|
-
* - `isUrlOnPrivateNetwork` *(this one)* which tests full URL
|
|
1691
|
-
* - `isHostnameOnPrivateNetwork` which tests just hostname
|
|
1692
|
-
*
|
|
1693
|
-
* @param {string} ipAddress - The IP address to check.
|
|
1694
|
-
* @returns {boolean} Returns true if the IP address is reserved for private networks or localhost, otherwise false.
|
|
1695
|
-
* @public exported from `@promptbook/utils`
|
|
1696
|
-
*/
|
|
1697
|
-
function isUrlOnPrivateNetwork(url) {
|
|
1698
|
-
if (typeof url === 'string') {
|
|
1699
|
-
url = new URL(url);
|
|
1700
|
-
}
|
|
1701
|
-
return isHostnameOnPrivateNetwork(url.hostname);
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
1653
|
/**
|
|
1705
1654
|
* Tests if given string is valid pipeline URL URL.
|
|
1706
1655
|
*
|
|
@@ -1714,16 +1663,19 @@
|
|
|
1714
1663
|
if (!isValidUrl(url)) {
|
|
1715
1664
|
return false;
|
|
1716
1665
|
}
|
|
1717
|
-
if (!url.startsWith('https://')) {
|
|
1666
|
+
if (!url.startsWith('https://') && !url.startsWith('http://') /* <- Note: [👣] */) {
|
|
1718
1667
|
return false;
|
|
1719
1668
|
}
|
|
1720
1669
|
if (url.includes('#')) {
|
|
1721
1670
|
// TODO: [🐠]
|
|
1722
1671
|
return false;
|
|
1723
1672
|
}
|
|
1673
|
+
/*
|
|
1674
|
+
Note: [👣][🧠] Is it secure to allow pipeline URLs on private and unsecured networks?
|
|
1724
1675
|
if (isUrlOnPrivateNetwork(url)) {
|
|
1725
1676
|
return false;
|
|
1726
1677
|
}
|
|
1678
|
+
*/
|
|
1727
1679
|
return true;
|
|
1728
1680
|
}
|
|
1729
1681
|
/**
|
|
@@ -2526,18 +2478,16 @@
|
|
|
2526
2478
|
*/
|
|
2527
2479
|
function createTask(options) {
|
|
2528
2480
|
var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
|
|
2529
|
-
var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO:
|
|
2481
|
+
var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */));
|
|
2530
2482
|
var partialResultSubject = new rxjs.BehaviorSubject({});
|
|
2531
2483
|
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2532
2484
|
partialResultSubject.next(newOngoingResult);
|
|
2533
2485
|
});
|
|
2534
2486
|
finalResultPromise
|
|
2535
2487
|
.catch(function (error) {
|
|
2536
|
-
// console.error('!!!!! Task failed:', error);
|
|
2537
2488
|
partialResultSubject.error(error);
|
|
2538
2489
|
})
|
|
2539
2490
|
.then(function (value) {
|
|
2540
|
-
// console.error('!!!!! Task finished:', value);
|
|
2541
2491
|
if (value) {
|
|
2542
2492
|
try {
|
|
2543
2493
|
assertsTaskSuccessful(value);
|
|
@@ -2559,9 +2509,7 @@
|
|
|
2559
2509
|
return [4 /*yield*/, finalResultPromise];
|
|
2560
2510
|
case 1:
|
|
2561
2511
|
finalResult = _b.sent();
|
|
2562
|
-
console.error('!!!!! finalResult:', finalResult);
|
|
2563
2512
|
if (isCrashedOnError) {
|
|
2564
|
-
console.error('!!!!! isCrashedOnError:', finalResult);
|
|
2565
2513
|
assertsTaskSuccessful(finalResult);
|
|
2566
2514
|
}
|
|
2567
2515
|
return [2 /*return*/, finalResult];
|