@promptbook/node 0.85.0-3 → 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
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
|
-
import { stat, access, constants, readFile, writeFile, readdir, mkdir, unlink } from '
|
|
3
|
-
import { basename, join, dirname } from '
|
|
2
|
+
import { stat, access, constants, readFile, writeFile, readdir, mkdir, unlink } from 'fs/promises';
|
|
3
|
+
import { basename, join, dirname } from 'path';
|
|
4
4
|
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
5
5
|
import { format } from 'prettier';
|
|
6
6
|
import parserHtml from 'prettier/parser-html';
|
|
7
|
-
import { BehaviorSubject
|
|
7
|
+
import { BehaviorSubject } from 'rxjs';
|
|
8
8
|
import { randomBytes } from 'crypto';
|
|
9
9
|
import { forTime } from 'waitasecond';
|
|
10
10
|
import { unparse, parse } from 'papaparse';
|
|
@@ -12,7 +12,7 @@ import hexEncoder from 'crypto-js/enc-hex';
|
|
|
12
12
|
import sha256 from 'crypto-js/sha256';
|
|
13
13
|
import { SHA256 } from 'crypto-js';
|
|
14
14
|
import { lookup, extension } from 'mime-types';
|
|
15
|
-
import { spawn } from '
|
|
15
|
+
import { spawn } from 'child_process';
|
|
16
16
|
import * as dotenv from 'dotenv';
|
|
17
17
|
|
|
18
18
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -29,7 +29,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
29
29
|
* @generated
|
|
30
30
|
* @see https://github.com/webgptorg/promptbook
|
|
31
31
|
*/
|
|
32
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-
|
|
32
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-4';
|
|
33
33
|
/**
|
|
34
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
35
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2044,11 +2044,29 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2044
2044
|
*/
|
|
2045
2045
|
function createTask(options) {
|
|
2046
2046
|
var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
|
|
2047
|
-
var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(
|
|
2047
|
+
var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: !!! To global config + Use Base58 to avoid simmilar char conflicts */));
|
|
2048
2048
|
var partialResultSubject = new BehaviorSubject({});
|
|
2049
2049
|
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2050
2050
|
partialResultSubject.next(newOngoingResult);
|
|
2051
2051
|
});
|
|
2052
|
+
finalResultPromise
|
|
2053
|
+
.catch(function (error) {
|
|
2054
|
+
// console.error('!!!!! Task failed:', error);
|
|
2055
|
+
partialResultSubject.error(error);
|
|
2056
|
+
})
|
|
2057
|
+
.then(function (value) {
|
|
2058
|
+
// console.error('!!!!! Task finished:', value);
|
|
2059
|
+
if (value) {
|
|
2060
|
+
try {
|
|
2061
|
+
assertsTaskSuccessful(value);
|
|
2062
|
+
partialResultSubject.next(value);
|
|
2063
|
+
}
|
|
2064
|
+
catch (error) {
|
|
2065
|
+
partialResultSubject.error(error);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
partialResultSubject.complete();
|
|
2069
|
+
});
|
|
2052
2070
|
function asPromise(options) {
|
|
2053
2071
|
return __awaiter(this, void 0, void 0, function () {
|
|
2054
2072
|
var _a, isCrashedOnError, finalResult;
|
|
@@ -2059,7 +2077,9 @@ function createTask(options) {
|
|
|
2059
2077
|
return [4 /*yield*/, finalResultPromise];
|
|
2060
2078
|
case 1:
|
|
2061
2079
|
finalResult = _b.sent();
|
|
2080
|
+
console.error('!!!!! finalResult:', finalResult);
|
|
2062
2081
|
if (isCrashedOnError) {
|
|
2082
|
+
console.error('!!!!! isCrashedOnError:', finalResult);
|
|
2063
2083
|
assertsTaskSuccessful(finalResult);
|
|
2064
2084
|
}
|
|
2065
2085
|
return [2 /*return*/, finalResult];
|
|
@@ -2072,9 +2092,10 @@ function createTask(options) {
|
|
|
2072
2092
|
taskId: taskId,
|
|
2073
2093
|
asPromise: asPromise,
|
|
2074
2094
|
asObservable: function () {
|
|
2075
|
-
return
|
|
2076
|
-
|
|
2077
|
-
|
|
2095
|
+
return partialResultSubject.asObservable();
|
|
2096
|
+
},
|
|
2097
|
+
get currentValue() {
|
|
2098
|
+
return partialResultSubject.value;
|
|
2078
2099
|
},
|
|
2079
2100
|
};
|
|
2080
2101
|
}
|