@promptbook/node 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 +332 -90
- 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 +334 -93
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -9,15 +9,16 @@ import { unparse, parse } from 'papaparse';
|
|
|
9
9
|
import { SHA256 } from 'crypto-js';
|
|
10
10
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
11
11
|
import { lookup } from 'mime-types';
|
|
12
|
+
import { exec as exec$2, spawn } from 'child_process';
|
|
13
|
+
import { promisify } from 'util';
|
|
12
14
|
import * as dotenv from 'dotenv';
|
|
13
15
|
import sha256 from 'crypto-js/sha256';
|
|
14
|
-
import { spawn } from 'child_process';
|
|
15
16
|
|
|
16
17
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
17
18
|
/**
|
|
18
19
|
* The version of the Promptbook library
|
|
19
20
|
*/
|
|
20
|
-
var PROMPTBOOK_VERSION = '0.71.0-
|
|
21
|
+
var PROMPTBOOK_VERSION = '0.71.0-22';
|
|
21
22
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
22
23
|
|
|
23
24
|
/*! *****************************************************************************
|
|
@@ -4729,7 +4730,6 @@ var $scrapersRegister = new $Register('scraper_constructors');
|
|
|
4729
4730
|
* TODO: [®] DRY Register logic
|
|
4730
4731
|
*/
|
|
4731
4732
|
|
|
4732
|
-
// TODO: !!!!!!last - Maybe delete this function
|
|
4733
4733
|
/**
|
|
4734
4734
|
* Creates a message with all registered scrapers
|
|
4735
4735
|
*
|
|
@@ -5002,7 +5002,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5002
5002
|
return __awaiter(this, void 0, void 0, function () {
|
|
5003
5003
|
var sourceContent, name, _b, _c, rootDirname, _d,
|
|
5004
5004
|
// <- TODO: process.cwd() if running in Node.js
|
|
5005
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension,
|
|
5005
|
+
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5006
5006
|
return __generator(this, function (_e) {
|
|
5007
5007
|
switch (_e.label) {
|
|
5008
5008
|
case 0:
|
|
@@ -5024,19 +5024,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5024
5024
|
filename: null,
|
|
5025
5025
|
url: url,
|
|
5026
5026
|
mimeType: mimeType,
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
return [2 /*return*/, content];
|
|
5036
|
-
}
|
|
5037
|
-
});
|
|
5038
|
-
});
|
|
5039
|
-
},
|
|
5027
|
+
/*
|
|
5028
|
+
TODO: [🥽]
|
|
5029
|
+
> async asBlob() {
|
|
5030
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
5031
|
+
> const content = await response.blob();
|
|
5032
|
+
> return content;
|
|
5033
|
+
> },
|
|
5034
|
+
*/
|
|
5040
5035
|
asJson: function () {
|
|
5041
5036
|
return __awaiter(this, void 0, void 0, function () {
|
|
5042
5037
|
var content;
|
|
@@ -5076,34 +5071,31 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5076
5071
|
}
|
|
5077
5072
|
filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
|
|
5078
5073
|
fileExtension = getFileExtension(filename_1);
|
|
5079
|
-
|
|
5074
|
+
mimeType = extensionToMimeType(fileExtension || '');
|
|
5080
5075
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5081
5076
|
case 3:
|
|
5082
5077
|
if (!(_e.sent())) {
|
|
5083
5078
|
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 "); }));
|
|
5084
5079
|
}
|
|
5085
|
-
// TODO:
|
|
5080
|
+
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
5086
5081
|
return [2 /*return*/, {
|
|
5087
5082
|
source: name,
|
|
5088
5083
|
filename: filename_1,
|
|
5089
5084
|
url: null,
|
|
5090
|
-
mimeType:
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
});
|
|
5105
|
-
});
|
|
5106
|
-
},
|
|
5085
|
+
mimeType: mimeType,
|
|
5086
|
+
/*
|
|
5087
|
+
TODO: [🥽]
|
|
5088
|
+
> async asBlob() {
|
|
5089
|
+
> const content = await tools.fs!.readFile(filename);
|
|
5090
|
+
> return new Blob(
|
|
5091
|
+
> [
|
|
5092
|
+
> content,
|
|
5093
|
+
> // <- TODO: [🥽] This is NOT tested, test it
|
|
5094
|
+
> ],
|
|
5095
|
+
> { type: mimeType },
|
|
5096
|
+
> );
|
|
5097
|
+
> },
|
|
5098
|
+
*/
|
|
5107
5099
|
asJson: function () {
|
|
5108
5100
|
return __awaiter(this, void 0, void 0, function () {
|
|
5109
5101
|
var _a, _b;
|
|
@@ -5139,9 +5131,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5139
5131
|
asJson: function () {
|
|
5140
5132
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
5141
5133
|
},
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5134
|
+
/*
|
|
5135
|
+
TODO: [🥽]
|
|
5136
|
+
> asBlob() {
|
|
5137
|
+
> throw new UnexpectedError(
|
|
5138
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
5139
|
+
> );
|
|
5140
|
+
> },
|
|
5141
|
+
*/
|
|
5145
5142
|
}];
|
|
5146
5143
|
}
|
|
5147
5144
|
});
|
|
@@ -5466,6 +5463,7 @@ var knowledgeCommandParser = {
|
|
|
5466
5463
|
'KNOWLEDGE ./hejny-cv.md',
|
|
5467
5464
|
'KNOWLEDGE ./hejny-cv.pdf',
|
|
5468
5465
|
'KNOWLEDGE ./hejny-cv.docx',
|
|
5466
|
+
// <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
|
|
5469
5467
|
],
|
|
5470
5468
|
/**
|
|
5471
5469
|
* Parses the KNOWLEDGE command
|
|
@@ -8183,6 +8181,301 @@ function pipelineStringToJson(pipelineString, tools, options) {
|
|
|
8183
8181
|
*/
|
|
8184
8182
|
var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
|
|
8185
8183
|
|
|
8184
|
+
// Note: We want to use the `exec` as async function
|
|
8185
|
+
var exec$1 = promisify(exec$2);
|
|
8186
|
+
/**
|
|
8187
|
+
* @@@
|
|
8188
|
+
*
|
|
8189
|
+
* @private within the repository
|
|
8190
|
+
*/
|
|
8191
|
+
function locateAppOnLinux(_a) {
|
|
8192
|
+
var appName = _a.appName, linuxWhich = _a.linuxWhich;
|
|
8193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8194
|
+
var _b, stderr, stdout;
|
|
8195
|
+
return __generator(this, function (_c) {
|
|
8196
|
+
switch (_c.label) {
|
|
8197
|
+
case 0: return [4 /*yield*/, exec$1("which ".concat(linuxWhich))];
|
|
8198
|
+
case 1:
|
|
8199
|
+
_b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
|
|
8200
|
+
if (!stderr && stdout) {
|
|
8201
|
+
return [2 /*return*/, stdout.trim()];
|
|
8202
|
+
}
|
|
8203
|
+
throw new Error("Can not locate app ".concat(appName, " on Linux.\n ").concat(stderr));
|
|
8204
|
+
}
|
|
8205
|
+
});
|
|
8206
|
+
});
|
|
8207
|
+
}
|
|
8208
|
+
/**
|
|
8209
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8210
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8211
|
+
*/
|
|
8212
|
+
|
|
8213
|
+
/**
|
|
8214
|
+
* @@@
|
|
8215
|
+
*
|
|
8216
|
+
* @public exported from `@promptbook/node`
|
|
8217
|
+
*/
|
|
8218
|
+
function $provideFilesystemForNode(options) {
|
|
8219
|
+
if (!$isRunningInNode()) {
|
|
8220
|
+
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8221
|
+
}
|
|
8222
|
+
var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
8223
|
+
TODO_USE(isVerbose);
|
|
8224
|
+
return {
|
|
8225
|
+
stat: stat,
|
|
8226
|
+
access: access,
|
|
8227
|
+
constants: constants,
|
|
8228
|
+
readFile: readFile,
|
|
8229
|
+
readdir: readdir,
|
|
8230
|
+
};
|
|
8231
|
+
}
|
|
8232
|
+
/**
|
|
8233
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8234
|
+
*/
|
|
8235
|
+
|
|
8236
|
+
/**
|
|
8237
|
+
* Checks if the file is executable
|
|
8238
|
+
*
|
|
8239
|
+
* @private within the repository
|
|
8240
|
+
*/
|
|
8241
|
+
function isExecutable(path, fs) {
|
|
8242
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8243
|
+
return __generator(this, function (_a) {
|
|
8244
|
+
switch (_a.label) {
|
|
8245
|
+
case 0:
|
|
8246
|
+
_a.trys.push([0, 2, , 3]);
|
|
8247
|
+
return [4 /*yield*/, fs.access(path, fs.constants.X_OK)];
|
|
8248
|
+
case 1:
|
|
8249
|
+
_a.sent();
|
|
8250
|
+
return [2 /*return*/, true];
|
|
8251
|
+
case 2:
|
|
8252
|
+
_a.sent();
|
|
8253
|
+
return [2 /*return*/, false];
|
|
8254
|
+
case 3: return [2 /*return*/];
|
|
8255
|
+
}
|
|
8256
|
+
});
|
|
8257
|
+
});
|
|
8258
|
+
}
|
|
8259
|
+
/**
|
|
8260
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
8261
|
+
* TODO: [🖇] What about symlinks?
|
|
8262
|
+
*/
|
|
8263
|
+
|
|
8264
|
+
// Note: Module `userhome` has no types available, so it is imported using `require`
|
|
8265
|
+
// @see https://stackoverflow.com/questions/37000981/how-to-import-node-module-in-typescript-without-type-definitions
|
|
8266
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8267
|
+
var userhome = require('userhome');
|
|
8268
|
+
// Note: We want to use the `exec` as async function
|
|
8269
|
+
var exec = promisify(exec$2);
|
|
8270
|
+
/**
|
|
8271
|
+
* @@@
|
|
8272
|
+
*
|
|
8273
|
+
* @private within the repository
|
|
8274
|
+
*/
|
|
8275
|
+
function locateAppOnMacOs(_a) {
|
|
8276
|
+
var appName = _a.appName, macOsName = _a.macOsName;
|
|
8277
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8278
|
+
var toExec, regPath, altPath, _b, stderr, stdout;
|
|
8279
|
+
return __generator(this, function (_c) {
|
|
8280
|
+
switch (_c.label) {
|
|
8281
|
+
case 0:
|
|
8282
|
+
toExec = "/Contents/MacOS/".concat(macOsName);
|
|
8283
|
+
regPath = "/Applications/".concat(macOsName, ".app") + toExec;
|
|
8284
|
+
altPath = userhome(regPath.slice(1));
|
|
8285
|
+
return [4 /*yield*/, isExecutable(regPath, $provideFilesystemForNode())];
|
|
8286
|
+
case 1:
|
|
8287
|
+
if (!_c.sent()) return [3 /*break*/, 2];
|
|
8288
|
+
return [2 /*return*/, regPath];
|
|
8289
|
+
case 2: return [4 /*yield*/, isExecutable(altPath, $provideFilesystemForNode())];
|
|
8290
|
+
case 3:
|
|
8291
|
+
if (_c.sent()) {
|
|
8292
|
+
return [2 /*return*/, altPath];
|
|
8293
|
+
}
|
|
8294
|
+
_c.label = 4;
|
|
8295
|
+
case 4: return [4 /*yield*/, exec("mdfind 'kMDItemDisplayName == \"".concat(macOsName, "\" && kMDItemKind == Application'"))];
|
|
8296
|
+
case 5:
|
|
8297
|
+
_b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
|
|
8298
|
+
if (!stderr && stdout) {
|
|
8299
|
+
return [2 /*return*/, stdout.trim() + toExec];
|
|
8300
|
+
}
|
|
8301
|
+
throw new Error("Can not locate app ".concat(appName, " on macOS.\n ").concat(stderr));
|
|
8302
|
+
}
|
|
8303
|
+
});
|
|
8304
|
+
});
|
|
8305
|
+
}
|
|
8306
|
+
/**
|
|
8307
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8308
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8309
|
+
*/
|
|
8310
|
+
|
|
8311
|
+
/**
|
|
8312
|
+
* @@@
|
|
8313
|
+
*
|
|
8314
|
+
* @private within the repository
|
|
8315
|
+
*/
|
|
8316
|
+
function locateAppOnWindows(_a) {
|
|
8317
|
+
var appName = _a.appName, windowsSuffix = _a.windowsSuffix;
|
|
8318
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8319
|
+
var prefixes, prefixes_1, prefixes_1_1, prefix, path, e_1_1;
|
|
8320
|
+
var e_1, _b;
|
|
8321
|
+
return __generator(this, function (_c) {
|
|
8322
|
+
switch (_c.label) {
|
|
8323
|
+
case 0:
|
|
8324
|
+
prefixes = [
|
|
8325
|
+
process.env.LOCALAPPDATA,
|
|
8326
|
+
join(process.env.LOCALAPPDATA || '', 'Programs'),
|
|
8327
|
+
process.env.PROGRAMFILES,
|
|
8328
|
+
process.env['PROGRAMFILES(X86)'],
|
|
8329
|
+
];
|
|
8330
|
+
_c.label = 1;
|
|
8331
|
+
case 1:
|
|
8332
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
8333
|
+
prefixes_1 = __values(prefixes), prefixes_1_1 = prefixes_1.next();
|
|
8334
|
+
_c.label = 2;
|
|
8335
|
+
case 2:
|
|
8336
|
+
if (!!prefixes_1_1.done) return [3 /*break*/, 5];
|
|
8337
|
+
prefix = prefixes_1_1.value;
|
|
8338
|
+
path = prefix + windowsSuffix;
|
|
8339
|
+
return [4 /*yield*/, isExecutable(path, $provideFilesystemForNode())];
|
|
8340
|
+
case 3:
|
|
8341
|
+
if (_c.sent()) {
|
|
8342
|
+
return [2 /*return*/, path];
|
|
8343
|
+
}
|
|
8344
|
+
_c.label = 4;
|
|
8345
|
+
case 4:
|
|
8346
|
+
prefixes_1_1 = prefixes_1.next();
|
|
8347
|
+
return [3 /*break*/, 2];
|
|
8348
|
+
case 5: return [3 /*break*/, 8];
|
|
8349
|
+
case 6:
|
|
8350
|
+
e_1_1 = _c.sent();
|
|
8351
|
+
e_1 = { error: e_1_1 };
|
|
8352
|
+
return [3 /*break*/, 8];
|
|
8353
|
+
case 7:
|
|
8354
|
+
try {
|
|
8355
|
+
if (prefixes_1_1 && !prefixes_1_1.done && (_b = prefixes_1.return)) _b.call(prefixes_1);
|
|
8356
|
+
}
|
|
8357
|
+
finally { if (e_1) throw e_1.error; }
|
|
8358
|
+
return [7 /*endfinally*/];
|
|
8359
|
+
case 8: throw new Error("Can not locate app ".concat(appName, " on Windows."));
|
|
8360
|
+
}
|
|
8361
|
+
});
|
|
8362
|
+
});
|
|
8363
|
+
}
|
|
8364
|
+
/**
|
|
8365
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8366
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8367
|
+
*/
|
|
8368
|
+
|
|
8369
|
+
/**
|
|
8370
|
+
* Locates an application on the system
|
|
8371
|
+
*
|
|
8372
|
+
* @private within the repository
|
|
8373
|
+
*/
|
|
8374
|
+
function locateApp(options) {
|
|
8375
|
+
if (!$isRunningInNode()) {
|
|
8376
|
+
throw new EnvironmentMismatchError('Locating apps works only in Node.js environment');
|
|
8377
|
+
}
|
|
8378
|
+
var appName = options.appName, linuxWhich = options.linuxWhich, windowsSuffix = options.windowsSuffix, macOsName = options.macOsName;
|
|
8379
|
+
if (process.platform === 'win32') {
|
|
8380
|
+
if (windowsSuffix) {
|
|
8381
|
+
return locateAppOnWindows({ appName: appName, windowsSuffix: windowsSuffix });
|
|
8382
|
+
}
|
|
8383
|
+
else {
|
|
8384
|
+
throw new Error("".concat(appName, " is not available on Windows."));
|
|
8385
|
+
}
|
|
8386
|
+
}
|
|
8387
|
+
else if (process.platform === 'darwin') {
|
|
8388
|
+
if (macOsName) {
|
|
8389
|
+
return locateAppOnMacOs({ appName: appName, macOsName: macOsName });
|
|
8390
|
+
}
|
|
8391
|
+
else {
|
|
8392
|
+
throw new Error("".concat(appName, " is not available on macOS."));
|
|
8393
|
+
}
|
|
8394
|
+
}
|
|
8395
|
+
else {
|
|
8396
|
+
if (linuxWhich) {
|
|
8397
|
+
return locateAppOnLinux({ appName: appName, linuxWhich: linuxWhich });
|
|
8398
|
+
}
|
|
8399
|
+
else {
|
|
8400
|
+
throw new Error("".concat(appName, " is not available on Linux."));
|
|
8401
|
+
}
|
|
8402
|
+
}
|
|
8403
|
+
}
|
|
8404
|
+
/**
|
|
8405
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8406
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8407
|
+
*/
|
|
8408
|
+
|
|
8409
|
+
/**
|
|
8410
|
+
* @@@
|
|
8411
|
+
*
|
|
8412
|
+
* @private within the repository
|
|
8413
|
+
*/
|
|
8414
|
+
function locateLibreoffice() {
|
|
8415
|
+
return locateApp({
|
|
8416
|
+
appName: 'Libreoffice',
|
|
8417
|
+
linuxWhich: 'libreoffice',
|
|
8418
|
+
windowsSuffix: '\\LibreOffice\\program\\soffice.exe',
|
|
8419
|
+
macOsName: 'LibreOffice',
|
|
8420
|
+
});
|
|
8421
|
+
}
|
|
8422
|
+
/**
|
|
8423
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
|
|
8424
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8425
|
+
*/
|
|
8426
|
+
|
|
8427
|
+
/**
|
|
8428
|
+
* @@@
|
|
8429
|
+
*
|
|
8430
|
+
* @private within the repository
|
|
8431
|
+
*/
|
|
8432
|
+
function locatePandoc() {
|
|
8433
|
+
return locateApp({
|
|
8434
|
+
appName: 'Pandoc',
|
|
8435
|
+
linuxWhich: 'pandoc',
|
|
8436
|
+
windowsSuffix: '\\Pandoc\\pandoc.exe',
|
|
8437
|
+
macOsName: 'Pandoc',
|
|
8438
|
+
});
|
|
8439
|
+
}
|
|
8440
|
+
/**
|
|
8441
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
|
|
8442
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8443
|
+
*/
|
|
8444
|
+
|
|
8445
|
+
/**
|
|
8446
|
+
* @@@
|
|
8447
|
+
*
|
|
8448
|
+
* @public exported from `@promptbook/node`
|
|
8449
|
+
*/
|
|
8450
|
+
function $provideExecutablesForNode(options) {
|
|
8451
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8452
|
+
var _a, _b, isAutoInstalled, _c, isVerbose;
|
|
8453
|
+
var _d;
|
|
8454
|
+
return __generator(this, function (_e) {
|
|
8455
|
+
switch (_e.label) {
|
|
8456
|
+
case 0:
|
|
8457
|
+
if (!$isRunningInNode()) {
|
|
8458
|
+
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8459
|
+
}
|
|
8460
|
+
_a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? DEFAULT_IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
|
|
8461
|
+
TODO_USE(isAutoInstalled); // <- TODO: [🔱][🧠] Auto-install the executables
|
|
8462
|
+
TODO_USE(isVerbose);
|
|
8463
|
+
_d = {};
|
|
8464
|
+
return [4 /*yield*/, locatePandoc()];
|
|
8465
|
+
case 1:
|
|
8466
|
+
_d.pandocPath = _e.sent();
|
|
8467
|
+
return [4 /*yield*/, locateLibreoffice()];
|
|
8468
|
+
case 2: return [2 /*return*/, (_d.libreOfficePath = _e.sent(),
|
|
8469
|
+
_d)];
|
|
8470
|
+
}
|
|
8471
|
+
});
|
|
8472
|
+
});
|
|
8473
|
+
}
|
|
8474
|
+
/**
|
|
8475
|
+
* TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
|
|
8476
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8477
|
+
*/
|
|
8478
|
+
|
|
8186
8479
|
/**
|
|
8187
8480
|
* @@@
|
|
8188
8481
|
*
|
|
@@ -8413,57 +8706,6 @@ function $provideLlmToolsFromEnv(options) {
|
|
|
8413
8706
|
* TODO: [®] DRY Register logic
|
|
8414
8707
|
*/
|
|
8415
8708
|
|
|
8416
|
-
/**
|
|
8417
|
-
* @@@
|
|
8418
|
-
*
|
|
8419
|
-
* @public exported from `@promptbook/node`
|
|
8420
|
-
*/
|
|
8421
|
-
function $provideExecutablesForNode(options) {
|
|
8422
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
8423
|
-
var _a, _b, isAutoInstalled, _c, isVerbose;
|
|
8424
|
-
return __generator(this, function (_d) {
|
|
8425
|
-
if (!$isRunningInNode()) {
|
|
8426
|
-
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8427
|
-
}
|
|
8428
|
-
_a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? DEFAULT_IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
|
|
8429
|
-
TODO_USE(isAutoInstalled);
|
|
8430
|
-
TODO_USE(isVerbose);
|
|
8431
|
-
return [2 /*return*/, {
|
|
8432
|
-
// TODO: !!!!!! use `locate-app` library here
|
|
8433
|
-
pandocPath: 'C:/Users/me/AppData/Local/Pandoc/pandoc.exe',
|
|
8434
|
-
libreOfficePath: 'C:/Program Files/LibreOffice/program/swriter.exe',
|
|
8435
|
-
}];
|
|
8436
|
-
});
|
|
8437
|
-
});
|
|
8438
|
-
}
|
|
8439
|
-
/**
|
|
8440
|
-
* TODO: [🧠] THis should be maybe in different folder
|
|
8441
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8442
|
-
*/
|
|
8443
|
-
|
|
8444
|
-
/**
|
|
8445
|
-
* @@@
|
|
8446
|
-
*
|
|
8447
|
-
* @public exported from `@promptbook/node`
|
|
8448
|
-
*/
|
|
8449
|
-
function $provideFilesystemForNode(options) {
|
|
8450
|
-
if (!$isRunningInNode()) {
|
|
8451
|
-
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8452
|
-
}
|
|
8453
|
-
var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
8454
|
-
TODO_USE(isVerbose);
|
|
8455
|
-
return {
|
|
8456
|
-
stat: stat,
|
|
8457
|
-
access: access,
|
|
8458
|
-
constants: constants,
|
|
8459
|
-
readFile: readFile,
|
|
8460
|
-
readdir: readdir,
|
|
8461
|
-
};
|
|
8462
|
-
}
|
|
8463
|
-
/**
|
|
8464
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8465
|
-
*/
|
|
8466
|
-
|
|
8467
8709
|
/**
|
|
8468
8710
|
* @@@
|
|
8469
8711
|
*
|