@promptbook/markdown-utils 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 +24 -6
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +32 -14
- package/umd/index.umd.js.map +1 -1
package/package.json
CHANGED
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('spacetrim'), require('prettier'), require('prettier/parser-html'), require('rxjs'), require('crypto'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.waitasecond, global.hexEncoder, global.sha256, global.
|
|
5
|
-
})(this, (function (exports, spaceTrim, prettier, parserHtml, rxjs, crypto, waitasecond, hexEncoder, sha256,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('rxjs'), require('crypto'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.waitasecond, global.hexEncoder, global.sha256, global.path, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, spaceTrim, prettier, parserHtml, rxjs, crypto, waitasecond, hexEncoder, sha256, path, cryptoJs, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -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-4';
|
|
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
|
|
@@ -2195,6 +2195,24 @@
|
|
|
2195
2195
|
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2196
2196
|
partialResultSubject.next(newOngoingResult);
|
|
2197
2197
|
});
|
|
2198
|
+
finalResultPromise
|
|
2199
|
+
.catch(function (error) {
|
|
2200
|
+
// console.error('!!!!! Task failed:', error);
|
|
2201
|
+
partialResultSubject.error(error);
|
|
2202
|
+
})
|
|
2203
|
+
.then(function (value) {
|
|
2204
|
+
// console.error('!!!!! Task finished:', value);
|
|
2205
|
+
if (value) {
|
|
2206
|
+
try {
|
|
2207
|
+
assertsTaskSuccessful(value);
|
|
2208
|
+
partialResultSubject.next(value);
|
|
2209
|
+
}
|
|
2210
|
+
catch (error) {
|
|
2211
|
+
partialResultSubject.error(error);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
partialResultSubject.complete();
|
|
2215
|
+
});
|
|
2198
2216
|
function asPromise(options) {
|
|
2199
2217
|
return __awaiter(this, void 0, void 0, function () {
|
|
2200
2218
|
var _a, isCrashedOnError, finalResult;
|
|
@@ -2205,7 +2223,9 @@
|
|
|
2205
2223
|
return [4 /*yield*/, finalResultPromise];
|
|
2206
2224
|
case 1:
|
|
2207
2225
|
finalResult = _b.sent();
|
|
2226
|
+
console.error('!!!!! finalResult:', finalResult);
|
|
2208
2227
|
if (isCrashedOnError) {
|
|
2228
|
+
console.error('!!!!! isCrashedOnError:', finalResult);
|
|
2209
2229
|
assertsTaskSuccessful(finalResult);
|
|
2210
2230
|
}
|
|
2211
2231
|
return [2 /*return*/, finalResult];
|
|
@@ -2218,9 +2238,7 @@
|
|
|
2218
2238
|
taskId: taskId,
|
|
2219
2239
|
asPromise: asPromise,
|
|
2220
2240
|
asObservable: function () {
|
|
2221
|
-
return
|
|
2222
|
-
isCrashedOnError: true,
|
|
2223
|
-
})));
|
|
2241
|
+
return partialResultSubject.asObservable();
|
|
2224
2242
|
},
|
|
2225
2243
|
get currentValue() {
|
|
2226
2244
|
return partialResultSubject.value;
|
|
@@ -3653,7 +3671,7 @@
|
|
|
3653
3671
|
value = value.replace(/\.html$/, '');
|
|
3654
3672
|
}
|
|
3655
3673
|
else if (isValidFilePath(value)) {
|
|
3656
|
-
value =
|
|
3674
|
+
value = path.basename(value);
|
|
3657
3675
|
// Note: Keeping extension in the name
|
|
3658
3676
|
}
|
|
3659
3677
|
value = value.split('/').join('-');
|
|
@@ -3759,9 +3777,9 @@
|
|
|
3759
3777
|
}
|
|
3760
3778
|
basename = url.split('/').pop() || titleToName(url);
|
|
3761
3779
|
hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
|
|
3762
|
-
rootDirname_1 =
|
|
3763
|
-
filepath =
|
|
3764
|
-
return [4 /*yield*/, tools.fs.mkdir(
|
|
3780
|
+
rootDirname_1 = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
3781
|
+
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));
|
|
3782
|
+
return [4 /*yield*/, tools.fs.mkdir(path.dirname(path.join(rootDirname_1, filepath)), { recursive: true })];
|
|
3765
3783
|
case 2:
|
|
3766
3784
|
_h.sent();
|
|
3767
3785
|
_g = (_f = Buffer).from;
|
|
@@ -3771,7 +3789,7 @@
|
|
|
3771
3789
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3772
3790
|
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."));
|
|
3773
3791
|
}
|
|
3774
|
-
return [4 /*yield*/, tools.fs.writeFile(
|
|
3792
|
+
return [4 /*yield*/, tools.fs.writeFile(path.join(rootDirname_1, filepath), fileContent)];
|
|
3775
3793
|
case 4:
|
|
3776
3794
|
_h.sent();
|
|
3777
3795
|
// TODO: [💵] Check the file security
|
|
@@ -3787,7 +3805,7 @@
|
|
|
3787
3805
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
3788
3806
|
// <- TODO: [🧠] What is the best error type here`
|
|
3789
3807
|
}
|
|
3790
|
-
filename_1 =
|
|
3808
|
+
filename_1 = path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
3791
3809
|
fileExtension = getFileExtension(filename_1);
|
|
3792
3810
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3793
3811
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|