@promptbook/documents 0.85.0-4 → 0.85.0-5
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 +26 -8
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +35 -17
- package/umd/index.umd.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/documents",
|
|
3
|
-
"version": "0.85.0-
|
|
3
|
+
"version": "0.85.0-5",
|
|
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,
|
|
@@ -47,7 +47,7 @@
|
|
|
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-
|
|
50
|
+
"@promptbook/core": "0.85.0-5"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-documents"] = {}, global.promises, global.spaceTrim, global.
|
|
5
|
-
})(this, (function (exports, promises, spaceTrim,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier'), require('prettier/parser-html'), require('rxjs'), require('crypto'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-documents"] = {}, global.promises, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.path, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, promises, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder, path, prettier, parserHtml, rxjs, crypto, sha256, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -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-
|
|
29
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-4';
|
|
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
|
|
@@ -508,7 +508,7 @@
|
|
|
508
508
|
console.info(colors__default["default"].yellow(cwd) + ' ' + colors__default["default"].green(command) + ' ' + colors__default["default"].blue(args.join(' ')));
|
|
509
509
|
}
|
|
510
510
|
try {
|
|
511
|
-
var commandProcess =
|
|
511
|
+
var commandProcess = child_process.spawn(command, args, { cwd: cwd, shell: true });
|
|
512
512
|
if (isVerbose) {
|
|
513
513
|
commandProcess.on('message', function (message) {
|
|
514
514
|
console.info({ message: message });
|
|
@@ -1058,7 +1058,7 @@
|
|
|
1058
1058
|
value = value.replace(/\.html$/, '');
|
|
1059
1059
|
}
|
|
1060
1060
|
else if (isValidFilePath(value)) {
|
|
1061
|
-
value =
|
|
1061
|
+
value = path.basename(value);
|
|
1062
1062
|
// Note: Keeping extension in the name
|
|
1063
1063
|
}
|
|
1064
1064
|
value = value.split('/').join('-');
|
|
@@ -1091,12 +1091,12 @@
|
|
|
1091
1091
|
semanticName = normalizeToKebabCase(titleToName((sourceFilename || url || '').split('intermediate').join(''))).substring(0, 20);
|
|
1092
1092
|
pieces = ['intermediate', semanticName, hash].filter(function (piece) { return piece !== ''; });
|
|
1093
1093
|
name = pieces.join('-').split('--').join('-');
|
|
1094
|
-
cacheFilename =
|
|
1094
|
+
cacheFilename = path.join.apply(void 0, __spreadArray(__spreadArray([process.cwd(),
|
|
1095
1095
|
cacheDirname], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), [name], false)).split('\\')
|
|
1096
1096
|
.join('/') +
|
|
1097
1097
|
'.' +
|
|
1098
1098
|
extension;
|
|
1099
|
-
return [4 /*yield*/, promises.mkdir(
|
|
1099
|
+
return [4 /*yield*/, promises.mkdir(path.dirname(cacheFilename), { recursive: true })];
|
|
1100
1100
|
case 1:
|
|
1101
1101
|
_a.sent();
|
|
1102
1102
|
isDestroyed = true;
|
|
@@ -2691,6 +2691,24 @@
|
|
|
2691
2691
|
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2692
2692
|
partialResultSubject.next(newOngoingResult);
|
|
2693
2693
|
});
|
|
2694
|
+
finalResultPromise
|
|
2695
|
+
.catch(function (error) {
|
|
2696
|
+
// console.error('!!!!! Task failed:', error);
|
|
2697
|
+
partialResultSubject.error(error);
|
|
2698
|
+
})
|
|
2699
|
+
.then(function (value) {
|
|
2700
|
+
// console.error('!!!!! Task finished:', value);
|
|
2701
|
+
if (value) {
|
|
2702
|
+
try {
|
|
2703
|
+
assertsTaskSuccessful(value);
|
|
2704
|
+
partialResultSubject.next(value);
|
|
2705
|
+
}
|
|
2706
|
+
catch (error) {
|
|
2707
|
+
partialResultSubject.error(error);
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
partialResultSubject.complete();
|
|
2711
|
+
});
|
|
2694
2712
|
function asPromise(options) {
|
|
2695
2713
|
return __awaiter(this, void 0, void 0, function () {
|
|
2696
2714
|
var _a, isCrashedOnError, finalResult;
|
|
@@ -2701,7 +2719,9 @@
|
|
|
2701
2719
|
return [4 /*yield*/, finalResultPromise];
|
|
2702
2720
|
case 1:
|
|
2703
2721
|
finalResult = _b.sent();
|
|
2722
|
+
console.error('!!!!! finalResult:', finalResult);
|
|
2704
2723
|
if (isCrashedOnError) {
|
|
2724
|
+
console.error('!!!!! isCrashedOnError:', finalResult);
|
|
2705
2725
|
assertsTaskSuccessful(finalResult);
|
|
2706
2726
|
}
|
|
2707
2727
|
return [2 /*return*/, finalResult];
|
|
@@ -2714,9 +2734,7 @@
|
|
|
2714
2734
|
taskId: taskId,
|
|
2715
2735
|
asPromise: asPromise,
|
|
2716
2736
|
asObservable: function () {
|
|
2717
|
-
return
|
|
2718
|
-
isCrashedOnError: true,
|
|
2719
|
-
})));
|
|
2737
|
+
return partialResultSubject.asObservable();
|
|
2720
2738
|
},
|
|
2721
2739
|
get currentValue() {
|
|
2722
2740
|
return partialResultSubject.value;
|
|
@@ -3837,9 +3855,9 @@
|
|
|
3837
3855
|
}
|
|
3838
3856
|
basename = url.split('/').pop() || titleToName(url);
|
|
3839
3857
|
hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
|
|
3840
|
-
rootDirname_1 =
|
|
3841
|
-
filepath =
|
|
3842
|
-
return [4 /*yield*/, tools.fs.mkdir(
|
|
3858
|
+
rootDirname_1 = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
3859
|
+
filepath = path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".").concat(mimeTypeToExtension(mimeType))], false));
|
|
3860
|
+
return [4 /*yield*/, tools.fs.mkdir(path.dirname(path.join(rootDirname_1, filepath)), { recursive: true })];
|
|
3843
3861
|
case 2:
|
|
3844
3862
|
_h.sent();
|
|
3845
3863
|
_g = (_f = Buffer).from;
|
|
@@ -3849,7 +3867,7 @@
|
|
|
3849
3867
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3850
3868
|
throw new LimitReachedError("File is too large (".concat(Math.round(fileContent.length / 1024 / 1024), "MB). Maximum allowed size is ").concat(Math.round(DEFAULT_MAX_FILE_SIZE / 1024 / 1024), "MB."));
|
|
3851
3869
|
}
|
|
3852
|
-
return [4 /*yield*/, tools.fs.writeFile(
|
|
3870
|
+
return [4 /*yield*/, tools.fs.writeFile(path.join(rootDirname_1, filepath), fileContent)];
|
|
3853
3871
|
case 4:
|
|
3854
3872
|
_h.sent();
|
|
3855
3873
|
// TODO: [💵] Check the file security
|
|
@@ -3865,7 +3883,7 @@
|
|
|
3865
3883
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
3866
3884
|
// <- TODO: [🧠] What is the best error type here`
|
|
3867
3885
|
}
|
|
3868
|
-
filename_1 =
|
|
3886
|
+
filename_1 = path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
3869
3887
|
fileExtension = getFileExtension(filename_1);
|
|
3870
3888
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3871
3889
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|