@promptbook/documents 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.
@@ -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 path - path to the directory with pipelines
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(path: string_dirname, tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options?: CreatePipelineCollectionFromDirectoryOptions): Promise<PipelineCollection>;
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: !!!!!!! CORS and security
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/documents",
3
- "version": "0.85.0-8",
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://www.npmjs.com/package/@promptbook/core",
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/documents.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.85.0-8"
50
+ "@promptbook/core": "0.85.0"
51
51
  },
52
52
  "dependencies": {
53
53
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -26,7 +26,7 @@
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- var PROMPTBOOK_ENGINE_VERSION = '0.85.0-7';
29
+ var PROMPTBOOK_ENGINE_VERSION = '0.85.0-16';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1826,57 +1826,6 @@
1826
1826
  return true;
1827
1827
  }
1828
1828
 
1829
- /**
1830
- * Checks if an URL is reserved for private networks or localhost.
1831
- *
1832
- * Note: There are two simmilar functions:
1833
- * - `isUrlOnPrivateNetwork` which tests full URL
1834
- * - `isHostnameOnPrivateNetwork` *(this one)* which tests just hostname
1835
- *
1836
- * @public exported from `@promptbook/utils`
1837
- */
1838
- function isHostnameOnPrivateNetwork(hostname) {
1839
- if (hostname === 'example.com' ||
1840
- hostname === 'localhost' ||
1841
- hostname.endsWith('.localhost') ||
1842
- hostname.endsWith('.local') ||
1843
- hostname.endsWith('.test') ||
1844
- hostname === '127.0.0.1' ||
1845
- hostname === '::1') {
1846
- return true;
1847
- }
1848
- if (hostname.includes(':')) {
1849
- // IPv6
1850
- var ipParts = hostname.split(':');
1851
- return ipParts[0] === 'fc00' || ipParts[0] === 'fd00' || ipParts[0] === 'fe80';
1852
- }
1853
- else {
1854
- // IPv4
1855
- var ipParts = hostname.split('.').map(function (part) { return Number.parseInt(part, 10); });
1856
- return (ipParts[0] === 10 ||
1857
- (ipParts[0] === 172 && ipParts[1] >= 16 && ipParts[1] <= 31) ||
1858
- (ipParts[0] === 192 && ipParts[1] === 168));
1859
- }
1860
- }
1861
-
1862
- /**
1863
- * Checks if an IP address or hostname is reserved for private networks or localhost.
1864
- *
1865
- * Note: There are two simmilar functions:
1866
- * - `isUrlOnPrivateNetwork` *(this one)* which tests full URL
1867
- * - `isHostnameOnPrivateNetwork` which tests just hostname
1868
- *
1869
- * @param {string} ipAddress - The IP address to check.
1870
- * @returns {boolean} Returns true if the IP address is reserved for private networks or localhost, otherwise false.
1871
- * @public exported from `@promptbook/utils`
1872
- */
1873
- function isUrlOnPrivateNetwork(url) {
1874
- if (typeof url === 'string') {
1875
- url = new URL(url);
1876
- }
1877
- return isHostnameOnPrivateNetwork(url.hostname);
1878
- }
1879
-
1880
1829
  /**
1881
1830
  * Tests if given string is valid pipeline URL URL.
1882
1831
  *
@@ -1890,16 +1839,19 @@
1890
1839
  if (!isValidUrl(url)) {
1891
1840
  return false;
1892
1841
  }
1893
- if (!url.startsWith('https://')) {
1842
+ if (!url.startsWith('https://') && !url.startsWith('http://') /* <- Note: [👣] */) {
1894
1843
  return false;
1895
1844
  }
1896
1845
  if (url.includes('#')) {
1897
1846
  // TODO: [🐠]
1898
1847
  return false;
1899
1848
  }
1849
+ /*
1850
+ Note: [👣][🧠] Is it secure to allow pipeline URLs on private and unsecured networks?
1900
1851
  if (isUrlOnPrivateNetwork(url)) {
1901
1852
  return false;
1902
1853
  }
1854
+ */
1903
1855
  return true;
1904
1856
  }
1905
1857
  /**
@@ -2686,18 +2638,16 @@
2686
2638
  */
2687
2639
  function createTask(options) {
2688
2640
  var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
2689
- var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: !!! To global config + Use Base58 to avoid simmilar char conflicts */));
2641
+ var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */));
2690
2642
  var partialResultSubject = new rxjs.BehaviorSubject({});
2691
2643
  var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
2692
2644
  partialResultSubject.next(newOngoingResult);
2693
2645
  });
2694
2646
  finalResultPromise
2695
2647
  .catch(function (error) {
2696
- // console.error('!!!!! Task failed:', error);
2697
2648
  partialResultSubject.error(error);
2698
2649
  })
2699
2650
  .then(function (value) {
2700
- // console.error('!!!!! Task finished:', value);
2701
2651
  if (value) {
2702
2652
  try {
2703
2653
  assertsTaskSuccessful(value);
@@ -2719,9 +2669,7 @@
2719
2669
  return [4 /*yield*/, finalResultPromise];
2720
2670
  case 1:
2721
2671
  finalResult = _b.sent();
2722
- console.error('!!!!! finalResult:', finalResult);
2723
2672
  if (isCrashedOnError) {
2724
- console.error('!!!!! isCrashedOnError:', finalResult);
2725
2673
  assertsTaskSuccessful(finalResult);
2726
2674
  }
2727
2675
  return [2 /*return*/, finalResult];