@promptbook/website-crawler 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
@@ -3,11 +3,11 @@ import { Readability } from '@mozilla/readability';
3
3
  import { JSDOM } from 'jsdom';
4
4
  import { SHA256 } from 'crypto-js';
5
5
  import hexEncoder from 'crypto-js/enc-hex';
6
- import { mkdir, rm } from 'node:fs/promises';
7
- import { basename, join, dirname } from 'node:path';
6
+ import { mkdir, rm } from 'fs/promises';
7
+ import { basename, join, dirname } from 'path';
8
8
  import { format } from 'prettier';
9
9
  import parserHtml from 'prettier/parser-html';
10
- import { BehaviorSubject, concat, from } from 'rxjs';
10
+ import { BehaviorSubject } from 'rxjs';
11
11
  import { randomBytes } from 'crypto';
12
12
  import { forTime } from 'waitasecond';
13
13
  import sha256 from 'crypto-js/sha256';
@@ -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-2';
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
@@ -2649,11 +2649,29 @@ function assertsTaskSuccessful(executionResult) {
2649
2649
  */
2650
2650
  function createTask(options) {
2651
2651
  var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
2652
- var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
2652
+ var taskId = "".concat(taskType.toLowerCase().substring(0, 4), "-").concat($randomToken(8 /* <- TODO: !!! To global config + Use Base58 to avoid simmilar char conflicts */));
2653
2653
  var partialResultSubject = new BehaviorSubject({});
2654
2654
  var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
2655
2655
  partialResultSubject.next(newOngoingResult);
2656
2656
  });
2657
+ finalResultPromise
2658
+ .catch(function (error) {
2659
+ // console.error('!!!!! Task failed:', error);
2660
+ partialResultSubject.error(error);
2661
+ })
2662
+ .then(function (value) {
2663
+ // console.error('!!!!! Task finished:', value);
2664
+ if (value) {
2665
+ try {
2666
+ assertsTaskSuccessful(value);
2667
+ partialResultSubject.next(value);
2668
+ }
2669
+ catch (error) {
2670
+ partialResultSubject.error(error);
2671
+ }
2672
+ }
2673
+ partialResultSubject.complete();
2674
+ });
2657
2675
  function asPromise(options) {
2658
2676
  return __awaiter(this, void 0, void 0, function () {
2659
2677
  var _a, isCrashedOnError, finalResult;
@@ -2664,7 +2682,9 @@ function createTask(options) {
2664
2682
  return [4 /*yield*/, finalResultPromise];
2665
2683
  case 1:
2666
2684
  finalResult = _b.sent();
2685
+ console.error('!!!!! finalResult:', finalResult);
2667
2686
  if (isCrashedOnError) {
2687
+ console.error('!!!!! isCrashedOnError:', finalResult);
2668
2688
  assertsTaskSuccessful(finalResult);
2669
2689
  }
2670
2690
  return [2 /*return*/, finalResult];
@@ -2677,9 +2697,10 @@ function createTask(options) {
2677
2697
  taskId: taskId,
2678
2698
  asPromise: asPromise,
2679
2699
  asObservable: function () {
2680
- return concat(partialResultSubject.asObservable(), from(asPromise({
2681
- isCrashedOnError: true,
2682
- })));
2700
+ return partialResultSubject.asObservable();
2701
+ },
2702
+ get currentValue() {
2703
+ return partialResultSubject.value;
2683
2704
  },
2684
2705
  };
2685
2706
  }