@promptbook/legacy-documents 0.85.0-1 → 0.85.0-11

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,14 +1,14 @@
1
- import { mkdir, rm, readFile, rmdir, rename, readdir } from 'node:fs/promises';
2
- import { basename, join, dirname } from 'node:path';
1
+ import { mkdir, rm, readFile, rmdir, rename, readdir } from 'fs/promises';
2
+ import { basename, join, dirname } from 'path';
3
3
  import spaceTrim$1, { spaceTrim } from 'spacetrim';
4
+ import { spawn } from 'child_process';
4
5
  import colors from 'colors';
5
- import { spawn } from 'node:child_process';
6
6
  import { forTime } from 'waitasecond';
7
7
  import { SHA256 } from 'crypto-js';
8
8
  import hexEncoder from 'crypto-js/enc-hex';
9
9
  import { format } from 'prettier';
10
10
  import parserHtml from 'prettier/parser-html';
11
- import { BehaviorSubject, concat, from } from 'rxjs';
11
+ import { BehaviorSubject } from 'rxjs';
12
12
  import { randomBytes } from 'crypto';
13
13
  import sha256 from 'crypto-js/sha256';
14
14
  import { lookup, extension } from 'mime-types';
@@ -28,7 +28,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- var PROMPTBOOK_ENGINE_VERSION = '0.85.0-0';
31
+ var PROMPTBOOK_ENGINE_VERSION = '0.85.0-10';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2688,11 +2688,27 @@ function assertsTaskSuccessful(executionResult) {
2688
2688
  */
2689
2689
  function createTask(options) {
2690
2690
  var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
2691
- var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
2691
+ var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */));
2692
2692
  var partialResultSubject = new BehaviorSubject({});
2693
2693
  var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
2694
2694
  partialResultSubject.next(newOngoingResult);
2695
2695
  });
2696
+ finalResultPromise
2697
+ .catch(function (error) {
2698
+ partialResultSubject.error(error);
2699
+ })
2700
+ .then(function (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
+ });
2696
2712
  function asPromise(options) {
2697
2713
  return __awaiter(this, void 0, void 0, function () {
2698
2714
  var _a, isCrashedOnError, finalResult;
@@ -2716,9 +2732,10 @@ function createTask(options) {
2716
2732
  taskId: taskId,
2717
2733
  asPromise: asPromise,
2718
2734
  asObservable: function () {
2719
- return concat(partialResultSubject.asObservable(), from(asPromise({
2720
- isCrashedOnError: true,
2721
- })));
2735
+ return partialResultSubject.asObservable();
2736
+ },
2737
+ get currentValue() {
2738
+ return partialResultSubject.value;
2722
2739
  },
2723
2740
  };
2724
2741
  }