@promptbook/pdf 0.88.0-1 → 0.88.0-8
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 -9
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/cli/cli-commands/common/handleActionErrors.d.ts +11 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +24 -0
- package/package.json +2 -2
- package/umd/index.umd.js +49 -8
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -5,7 +5,7 @@ import hexEncoder from 'crypto-js/enc-hex';
|
|
|
5
5
|
import { basename, join, dirname } from 'path';
|
|
6
6
|
import { format } from 'prettier';
|
|
7
7
|
import parserHtml from 'prettier/parser-html';
|
|
8
|
-
import {
|
|
8
|
+
import { Subject } from 'rxjs';
|
|
9
9
|
import { randomBytes } from 'crypto';
|
|
10
10
|
import { forTime } from 'waitasecond';
|
|
11
11
|
import sha256 from 'crypto-js/sha256';
|
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-8';
|
|
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
|
|
@@ -2307,21 +2307,41 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2307
2307
|
function createTask(options) {
|
|
2308
2308
|
const { taskType, taskProcessCallback } = options;
|
|
2309
2309
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2310
|
-
|
|
2310
|
+
let status = 'RUNNING';
|
|
2311
|
+
const createdAt = new Date();
|
|
2312
|
+
let updatedAt = createdAt;
|
|
2313
|
+
const errors = [];
|
|
2314
|
+
const warnings = [];
|
|
2315
|
+
const currentValue = {};
|
|
2316
|
+
const partialResultSubject = new Subject();
|
|
2317
|
+
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2311
2318
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2319
|
+
Object.assign(currentValue, newOngoingResult);
|
|
2312
2320
|
partialResultSubject.next(newOngoingResult);
|
|
2313
2321
|
});
|
|
2314
2322
|
finalResultPromise
|
|
2315
2323
|
.catch((error) => {
|
|
2324
|
+
errors.push(error);
|
|
2316
2325
|
partialResultSubject.error(error);
|
|
2317
2326
|
})
|
|
2318
|
-
.then((
|
|
2319
|
-
if (
|
|
2327
|
+
.then((executionResult) => {
|
|
2328
|
+
if (executionResult) {
|
|
2320
2329
|
try {
|
|
2321
|
-
|
|
2322
|
-
|
|
2330
|
+
updatedAt = new Date();
|
|
2331
|
+
errors.push(...executionResult.errors);
|
|
2332
|
+
warnings.push(...executionResult.warnings);
|
|
2333
|
+
// <- TODO: !!! Only unique errors and warnings should be added (or filtered)
|
|
2334
|
+
// TODO: [🧠] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
2335
|
+
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
2336
|
+
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2337
|
+
assertsTaskSuccessful(executionResult);
|
|
2338
|
+
status = 'FINISHED';
|
|
2339
|
+
Object.assign(currentValue, executionResult);
|
|
2340
|
+
partialResultSubject.next(executionResult);
|
|
2323
2341
|
}
|
|
2324
2342
|
catch (error) {
|
|
2343
|
+
status = 'ERROR';
|
|
2344
|
+
errors.push(error);
|
|
2325
2345
|
partialResultSubject.error(error);
|
|
2326
2346
|
}
|
|
2327
2347
|
}
|
|
@@ -2338,12 +2358,33 @@ function createTask(options) {
|
|
|
2338
2358
|
return {
|
|
2339
2359
|
taskType,
|
|
2340
2360
|
taskId,
|
|
2361
|
+
get status() {
|
|
2362
|
+
return status;
|
|
2363
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2364
|
+
},
|
|
2365
|
+
get createdAt() {
|
|
2366
|
+
return createdAt;
|
|
2367
|
+
// <- Note: [1]
|
|
2368
|
+
},
|
|
2369
|
+
get updatedAt() {
|
|
2370
|
+
return updatedAt;
|
|
2371
|
+
// <- Note: [1]
|
|
2372
|
+
},
|
|
2341
2373
|
asPromise,
|
|
2342
2374
|
asObservable() {
|
|
2343
2375
|
return partialResultSubject.asObservable();
|
|
2344
2376
|
},
|
|
2377
|
+
get errors() {
|
|
2378
|
+
return errors;
|
|
2379
|
+
// <- Note: [1]
|
|
2380
|
+
},
|
|
2381
|
+
get warnings() {
|
|
2382
|
+
return warnings;
|
|
2383
|
+
// <- Note: [1]
|
|
2384
|
+
},
|
|
2345
2385
|
get currentValue() {
|
|
2346
|
-
return
|
|
2386
|
+
return currentValue;
|
|
2387
|
+
// <- Note: [1]
|
|
2347
2388
|
},
|
|
2348
2389
|
};
|
|
2349
2390
|
}
|
|
@@ -4718,7 +4759,7 @@ async function executeAttempts(options) {
|
|
|
4718
4759
|
Last result:
|
|
4719
4760
|
${block($ongoingTaskResult.$resultString === null
|
|
4720
4761
|
? 'null'
|
|
4721
|
-
: $ongoingTaskResult.$resultString
|
|
4762
|
+
: spaceTrim$1($ongoingTaskResult.$resultString)
|
|
4722
4763
|
.split('\n')
|
|
4723
4764
|
.map((line) => `> ${line}`)
|
|
4724
4765
|
.join('\n'))}
|