@promptbook/legacy-documents 0.71.0-20 → 0.71.0-23
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/esm/index.es.js +50 -44
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/{scrapers/_common/register → executables}/$provideExecutablesForNode.d.ts +3 -3
- package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
- package/esm/typings/src/executables/apps/locateLibreoffice.test.d.ts +1 -0
- package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
- package/esm/typings/src/executables/apps/locatePandoc.test.d.ts +1 -0
- package/esm/typings/src/executables/locateApp.d.ts +33 -0
- package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
- package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -4
- package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
- package/package.json +2 -2
- package/umd/index.umd.js +50 -44
- package/umd/index.umd.js.map +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PROMPTBOOK_VERSION } from '../version';
|
|
2
2
|
import { createCollectionFromDirectory } from '../collection/constructors/createCollectionFromDirectory';
|
|
3
|
+
import { $provideExecutablesForNode } from '../executables/$provideExecutablesForNode';
|
|
3
4
|
import { $provideExecutionToolsForNode } from '../execution/utils/$provideExecutionToolsForNode';
|
|
4
5
|
import { $provideLlmToolsConfigurationFromEnv } from '../llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv';
|
|
5
6
|
import { $provideLlmToolsFromEnv } from '../llm-providers/_common/register/$provideLlmToolsFromEnv';
|
|
6
|
-
import { $provideExecutablesForNode } from '../scrapers/_common/register/$provideExecutablesForNode';
|
|
7
7
|
import { $provideFilesystemForNode } from '../scrapers/_common/register/$provideFilesystemForNode';
|
|
8
8
|
import { $provideScrapersForNode } from '../scrapers/_common/register/$provideScrapersForNode';
|
|
9
9
|
import { FileCacheStorage } from '../storage/file-cache-storage/FileCacheStorage';
|
|
@@ -11,10 +11,10 @@ import { $execCommand } from '../utils/execCommand/$execCommand';
|
|
|
11
11
|
import { $execCommands } from '../utils/execCommand/$execCommands';
|
|
12
12
|
export { PROMPTBOOK_VERSION };
|
|
13
13
|
export { createCollectionFromDirectory };
|
|
14
|
+
export { $provideExecutablesForNode };
|
|
14
15
|
export { $provideExecutionToolsForNode };
|
|
15
16
|
export { $provideLlmToolsConfigurationFromEnv };
|
|
16
17
|
export { $provideLlmToolsFromEnv };
|
|
17
|
-
export { $provideExecutablesForNode };
|
|
18
18
|
export { $provideFilesystemForNode };
|
|
19
19
|
export { $provideScrapersForNode };
|
|
20
20
|
export { FileCacheStorage };
|
|
@@ -14,6 +14,7 @@ import type { PrettifyOptions } from '../conversion/prettify/PrettifyOptions';
|
|
|
14
14
|
import type { renderPipelineMermaidOptions } from '../conversion/prettify/renderPipelineMermaidOptions';
|
|
15
15
|
import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
|
|
16
16
|
import type { ErrorJson } from '../errors/utils/ErrorJson';
|
|
17
|
+
import type { LocateAppOptions } from '../executables/locateApp';
|
|
17
18
|
import type { AvailableModel } from '../execution/AvailableModel';
|
|
18
19
|
import type { CommonToolsOptions } from '../execution/CommonToolsOptions';
|
|
19
20
|
import type { CreatePipelineExecutorOptions } from '../execution/createPipelineExecutor/00-CreatePipelineExecutorOptions';
|
|
@@ -254,6 +255,7 @@ export type { PrettifyOptions };
|
|
|
254
255
|
export type { renderPipelineMermaidOptions };
|
|
255
256
|
export type { CallbackInterfaceToolsOptions };
|
|
256
257
|
export type { ErrorJson };
|
|
258
|
+
export type { LocateAppOptions };
|
|
257
259
|
export type { AvailableModel };
|
|
258
260
|
export type { CommonToolsOptions };
|
|
259
261
|
export type { CreatePipelineExecutorOptions };
|
package/esm/typings/src/{scrapers/_common/register → executables}/$provideExecutablesForNode.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Executables } from '
|
|
2
|
-
import type { PrepareAndScrapeOptions } from '
|
|
1
|
+
import type { Executables } from '../execution/Executables';
|
|
2
|
+
import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
|
|
3
3
|
/**
|
|
4
4
|
* @@@
|
|
5
5
|
*
|
|
@@ -7,6 +7,6 @@ import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeO
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function $provideExecutablesForNode(options?: PrepareAndScrapeOptions): Promise<Executables>;
|
|
9
9
|
/**
|
|
10
|
-
* TODO: [🧠]
|
|
10
|
+
* TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
|
|
11
11
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
12
12
|
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*
|
|
5
|
+
* @private within the repository
|
|
6
|
+
*/
|
|
7
|
+
export declare function locateLibreoffice(): Promise<string_executable_path>;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
|
|
10
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
11
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*
|
|
5
|
+
* @private within the repository
|
|
6
|
+
*/
|
|
7
|
+
export declare function locatePandoc(): Promise<string_executable_path>;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
|
|
10
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
11
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
2
|
+
import type { string_executable_path } from '../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Options for locating any application
|
|
5
|
+
*/
|
|
6
|
+
export interface LocateAppOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Name of the application
|
|
9
|
+
*/
|
|
10
|
+
appName: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name of the executable on Linux
|
|
13
|
+
*/
|
|
14
|
+
linuxWhich?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Path suffix on Windows
|
|
17
|
+
*/
|
|
18
|
+
windowsSuffix?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Name of the application on macOS
|
|
21
|
+
*/
|
|
22
|
+
macOsName?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Locates an application on the system
|
|
26
|
+
*
|
|
27
|
+
* @private within the repository
|
|
28
|
+
*/
|
|
29
|
+
export declare function locateApp(options: RequireAtLeastOne<LocateAppOptions, 'linuxWhich' | 'windowsSuffix' | 'macOsName'>): Promise<string_executable_path>;
|
|
30
|
+
/**
|
|
31
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
32
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
33
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LocateAppOptions } from '../locateApp';
|
|
2
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function locateAppOnLinux({ appName, linuxWhich, }: Pick<Required<LocateAppOptions>, 'appName' | 'linuxWhich'>): Promise<string_executable_path>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
11
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
12
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
2
|
+
import type { LocateAppOptions } from '../locateApp';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function locateAppOnMacOs({ appName, macOsName, }: Pick<Required<LocateAppOptions>, 'appName' | 'macOsName'>): Promise<string_executable_path>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
11
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
12
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_executable_path } from '../../types/typeAliases';
|
|
2
|
+
import type { LocateAppOptions } from '../locateApp';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*
|
|
6
|
+
* @private within the repository
|
|
7
|
+
*/
|
|
8
|
+
export declare function locateAppOnWindows({ appName, windowsSuffix, }: Pick<Required<LocateAppOptions>, 'appName' | 'windowsSuffix'>): Promise<string_executable_path>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
11
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
12
|
+
*/
|
|
@@ -51,12 +51,9 @@ export type ScraperSourceHandler = {
|
|
|
51
51
|
* Get the content as a utf-8 string
|
|
52
52
|
*/
|
|
53
53
|
asText(): Promisable<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Get the content as a blob
|
|
56
|
-
*/
|
|
57
|
-
asBlob(): Promisable<Blob>;
|
|
58
54
|
};
|
|
59
55
|
/**
|
|
56
|
+
* TODO: [🥽] Add ` asBlob(): Promisable<Blob>;` or asFile
|
|
60
57
|
* TODO: [🐝] @@@ Annotate all
|
|
61
58
|
* TODO: [🔼] Export via types
|
|
62
59
|
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FilesystemTools } from '../../execution/FilesystemTools';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the file is executable
|
|
4
|
+
*
|
|
5
|
+
* @private within the repository
|
|
6
|
+
*/
|
|
7
|
+
export declare function isExecutable(path: string, fs: FilesystemTools): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
10
|
+
* TODO: [🖇] What about symlinks?
|
|
11
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/legacy-documents",
|
|
3
|
-
"version": "0.71.0-
|
|
3
|
+
"version": "0.71.0-23",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"module": "./esm/index.es.js",
|
|
53
53
|
"typings": "./esm/typings/src/_packages/legacy-documents.index.d.ts",
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@promptbook/core": "0.71.0-
|
|
55
|
+
"@promptbook/core": "0.71.0-23"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
/**
|
|
16
16
|
* The version of the Promptbook library
|
|
17
17
|
*/
|
|
18
|
-
var PROMPTBOOK_VERSION = '0.71.0-
|
|
18
|
+
var PROMPTBOOK_VERSION = '0.71.0-22';
|
|
19
19
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
20
20
|
|
|
21
21
|
/*! *****************************************************************************
|
|
@@ -3099,7 +3099,6 @@
|
|
|
3099
3099
|
* TODO: [®] DRY Register logic
|
|
3100
3100
|
*/
|
|
3101
3101
|
|
|
3102
|
-
// TODO: !!!!!!last - Maybe delete this function
|
|
3103
3102
|
/**
|
|
3104
3103
|
* Creates a message with all registered scrapers
|
|
3105
3104
|
*
|
|
@@ -3241,7 +3240,7 @@
|
|
|
3241
3240
|
return __awaiter(this, void 0, void 0, function () {
|
|
3242
3241
|
var sourceContent, name, _b, _c, rootDirname, _d,
|
|
3243
3242
|
// <- TODO: process.cwd() if running in Node.js
|
|
3244
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension,
|
|
3243
|
+
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3245
3244
|
return __generator(this, function (_e) {
|
|
3246
3245
|
switch (_e.label) {
|
|
3247
3246
|
case 0:
|
|
@@ -3263,19 +3262,14 @@
|
|
|
3263
3262
|
filename: null,
|
|
3264
3263
|
url: url,
|
|
3265
3264
|
mimeType: mimeType,
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
return [2 /*return*/, content];
|
|
3275
|
-
}
|
|
3276
|
-
});
|
|
3277
|
-
});
|
|
3278
|
-
},
|
|
3265
|
+
/*
|
|
3266
|
+
TODO: [🥽]
|
|
3267
|
+
> async asBlob() {
|
|
3268
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
3269
|
+
> const content = await response.blob();
|
|
3270
|
+
> return content;
|
|
3271
|
+
> },
|
|
3272
|
+
*/
|
|
3279
3273
|
asJson: function () {
|
|
3280
3274
|
return __awaiter(this, void 0, void 0, function () {
|
|
3281
3275
|
var content;
|
|
@@ -3315,34 +3309,31 @@
|
|
|
3315
3309
|
}
|
|
3316
3310
|
filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
|
|
3317
3311
|
fileExtension = getFileExtension(filename_1);
|
|
3318
|
-
|
|
3312
|
+
mimeType = extensionToMimeType(fileExtension || '');
|
|
3319
3313
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3320
3314
|
case 3:
|
|
3321
3315
|
if (!(_e.sent())) {
|
|
3322
3316
|
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 "); }));
|
|
3323
3317
|
}
|
|
3324
|
-
// TODO:
|
|
3318
|
+
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
3325
3319
|
return [2 /*return*/, {
|
|
3326
3320
|
source: name,
|
|
3327
3321
|
filename: filename_1,
|
|
3328
3322
|
url: null,
|
|
3329
|
-
mimeType:
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
});
|
|
3344
|
-
});
|
|
3345
|
-
},
|
|
3323
|
+
mimeType: mimeType,
|
|
3324
|
+
/*
|
|
3325
|
+
TODO: [🥽]
|
|
3326
|
+
> async asBlob() {
|
|
3327
|
+
> const content = await tools.fs!.readFile(filename);
|
|
3328
|
+
> return new Blob(
|
|
3329
|
+
> [
|
|
3330
|
+
> content,
|
|
3331
|
+
> // <- TODO: [🥽] This is NOT tested, test it
|
|
3332
|
+
> ],
|
|
3333
|
+
> { type: mimeType },
|
|
3334
|
+
> );
|
|
3335
|
+
> },
|
|
3336
|
+
*/
|
|
3346
3337
|
asJson: function () {
|
|
3347
3338
|
return __awaiter(this, void 0, void 0, function () {
|
|
3348
3339
|
var _a, _b;
|
|
@@ -3378,9 +3369,14 @@
|
|
|
3378
3369
|
asJson: function () {
|
|
3379
3370
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
3380
3371
|
},
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3372
|
+
/*
|
|
3373
|
+
TODO: [🥽]
|
|
3374
|
+
> asBlob() {
|
|
3375
|
+
> throw new UnexpectedError(
|
|
3376
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
3377
|
+
> );
|
|
3378
|
+
> },
|
|
3379
|
+
*/
|
|
3384
3380
|
}];
|
|
3385
3381
|
}
|
|
3386
3382
|
});
|
|
@@ -6035,9 +6031,14 @@
|
|
|
6035
6031
|
asJson: function () {
|
|
6036
6032
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
6037
6033
|
},
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6034
|
+
/*
|
|
6035
|
+
TODO: [🥽]
|
|
6036
|
+
> asBlob() {
|
|
6037
|
+
> throw new UnexpectedError(
|
|
6038
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
6039
|
+
> );
|
|
6040
|
+
> },
|
|
6041
|
+
*/
|
|
6041
6042
|
};
|
|
6042
6043
|
knowledge = this.markdownScraper.scrape(markdownSource);
|
|
6043
6044
|
return [4 /*yield*/, cacheFilehandler.destroy()];
|
|
@@ -6203,9 +6204,14 @@
|
|
|
6203
6204
|
asJson: function () {
|
|
6204
6205
|
throw new UnexpectedError('Did not expect that `documentScraper` would need to get the content `asJson`');
|
|
6205
6206
|
},
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6207
|
+
/*
|
|
6208
|
+
TODO: [🥽]
|
|
6209
|
+
> asBlob() {
|
|
6210
|
+
> throw new UnexpectedError(
|
|
6211
|
+
> 'Did not expect that `documentScraper` would need to get the content `asBlob`',
|
|
6212
|
+
> );
|
|
6213
|
+
> },
|
|
6214
|
+
*/
|
|
6209
6215
|
};
|
|
6210
6216
|
knowledge = this.documentScraper.scrape(markdownSource);
|
|
6211
6217
|
return [4 /*yield*/, cacheFilehandler.destroy()];
|